web analytics

Changing the background color of a dialog

I have found this proper way to set the color of CDialog in MFC application.

Write this Function in your class.

HBRUSH CCaptureOPtionsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
if( nCtlColor == 6 ) // for Slider control
pDC->SetBkMode(TRANSPARENT);// Set the Background Mode to TRANSPARENT }

else if( nCtlColor == CTLCOLOR_DLG ) // for dialog
pDC->SetTextColor(RGB(0, 0, 0)); // set the Text Color; black
pDC->SetBkMode(TRANSPARENT); // Set the Background Mode to TRANSPARENT
m_brush.CreateSolidBrush(RGB(214, 211, 206)); // Set RGB color any you want for your Dialog
return m_brush;

Leave a Reply

%d bloggers like this: