Hi ,
1. im doing a program to change the colour of push button,edit,check box by choosing the colour from combo box by clicking push button. My problem is the push button colour is not changing ,, please help me to change the colour of the push button
2. if the push button is clicked without choosing the colour from the combo box,, a message must appear as "select a color".
3.how to change the colour of check box[the white area inside the check box]
I searched for the code but i didnt get it,, it will be helpfull if you give me the codes
thank you
this is my code
void CComboTestDlg::OnButton1()
{
int index = m_ColorCombo.GetCurSel();
if(index != CB_ERR)
{
m_brush.DeleteObject();
switch(index)
{
case 0:
m_brush.CreateSolidBrush(RGB(0, 240, 120));
break;
case 1:
m_brush.CreateSolidBrush(RGB(128, 0, 240));
break;
case 2:
m_brush.CreateSolidBrush(RGB(0, 128, 0));
break;
case 3:
m_brush.CreateSolidBrush(RGB(128, 128, 0));
break;
case 4:
m_brush.CreateSolidBrush(RGB(0, 0, 128));
break;
default:
m_brush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
break;
}
Invalidate(TRUE);
}
else
{
AfxMessageBox("Select a color ");
}
}
HBRUSH CComboTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch ( nCtlColor )
{
case CTLCOLOR_EDIT:
case CTLCOLOR_MSGBOX:
case CTLCOLOR_BTN:
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(0, 240, 120));
pDC->SetBkColor(RGB(0, 0, 0));
return (HBRUSH)(m_brush.GetSafeHandle());
case CTLCOLOR_DLG:
return static_cast<HBRUSH> ( m_brush.GetSafeHandle() );
}
}
thank you in advance
AJ