Hi,
I want to change the color of my button during runtime..
i am writing the following code inthe OnCtlColor of my dialog box
HBRUSH CPIVSyncDlg::OnCtlColor(CDC *pdc,CWnd *pwnd,UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pdc,pwnd,nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_BTN:
if(pwnd->GetDlgCtrlID() == IDC_STARTSTOP)
pdc->SetBkColor(RGB(255,0,0));
return (HBRUSH)m_btbrush.GetSafeHandle();
case CTLCOLOR_DLG:
pdc->SetBkColor(RGB(255,255,255));
pdc->SetBkMode(TRANSPARENT);
return (HBRUSH)m_hbrush.GetSafeHandle();
case CTLCOLOR_EDIT:
pdc->SetBkColor(RGB(0,0,0));
pdc->SetBkMode(TRANSPARENT);
return (HBRUSH)m_hbrush.GetSafeHandle();
default:
return CDialog::OnCtlColor(pdc,pwnd,nCtlColor);
}
return hbr;
//return (HBRUSH)m_hbrush.GetSafeHandle();
}
the button is IDC_STARTSTOP i want to turn it red..but the interesting thing is the whole dialog box turns red except the buttons...
i have searched the msdn library and I am following all the instruction given in example ...all in vein... any suggestion would be helpful..
thanks,
Hardik