المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Changing the color of a button [modified]



C++ Programming
10-06-2009, 12:01 AM
Anyone know how to change the background color of a button using CColorDialog?

Will this work?
void CCustomButtonDlg::OnButtonFace()
{

CColorDialog dlg;

dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT ;
dlg.m_cc.rgbResult = RGB( 255, 0, 0 );
dlg.DoModal();

HBRUSH hbr;

if (GetDlgCtrlID() == IDC_CUSTOM_BUTTON)
{
CDC *cDC;
cDC = m_CustomButton.GetDC();
cDC->SetBkColor(dlg.GetColor());
hbr = m_brush;
}

UpdateData();
}

modified on Monday, October 5, 2009 5:39 AM