mfc获取颜色对话框并在文本框中显示?

2025-04-08 03:58:33
推荐回答(1个)
回答1:

COLORREF color = RGB(255, 0, 0);
CColorDialog cdlg(color);
if (IDOK == cdlg.DoModal())
{
color = cdlg.GetColor();
CString str;
str.Format(_T("%d"), GetRValue(color));
GetDlgItem(IDC_EDIT2)->SetWindowTextW(str);
str.Format(_T("%d"), GetGValue(color));
GetDlgItem(IDC_EDIT3)->SetWindowTextW(str);
str.Format(_T("%d"), GetBValue(color));
GetDlgItem(IDC_EDIT4)->SetWindowTextW(str);
}