(1) CXXXDLG Add brush variable
CBrush M_brush; Brush
(2) Initialize brush in OnInitDialog method
M_brush. CreateSolidBrush (RGB (0x83,0xa5,0xd2));
(2) Implement the OnCtlColor function of window
Hbrush Cxxxdlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor)
{
Hbrush HBR = Cdialog::onctlcolor (PDC, PWnd, nCtlColor);
if (pwnd->getdlgctrlid () = = Idc_static_video)
{
Pdc->setbkmode (TRANSPARENT);
Return m_brush;//Custom Brush Brush
}
if (pwnd->getdlgctrlid () = = Idc_static_alarm_txt)
{
Pdc->settextcolor (RGB (0xe6,0x00,0x12));//custom control text color
}
if (pwnd->getdlgctrlid () = = Idc_static_wndid)
{
Pdc->settextcolor (RGB (0X83,0XA5,0XD2));//custom control text color
}
TODO: Change any of the properties of the DC here
TODO: If the default is not the desired brush, another brush is returned
return HBR;
}
customizing control text colors and control backgrounds