MFC 颜色选择对话框、颜色按钮

时间:2022-04-20 19:21:53

COLORREF color=RGB(0,255,0);

unsigned char r=GetRValue(color);

unsigned char g=GetGValue(color);

unsigned char b=GetBValue(color);

-------------------------------------

CColorDialog colorDialog;
COLORREF color;
if( colorDialog.DoModal() == IDOK )
{
     color = colorDialog.GetColor();
}

-------------------------------------

((CMFCColorButton*)GetDlgItem(IDC_MFCCOLORBUTTON1))->SetColor(RGB(204,204,204));

COLORREF color=((CMFCColorButton*)GetDlgItem(IDC_MFCCOLORBUTTON1))->GetColor();