OnCtlColor has the following macro definitions
#define Ctlcolor_msgbox 0
#define CTLCOLOR_EDIT 1
#define Ctlcolor_listbox 2//Edit drop-down list color
#define CTLCOLOR_BTN 3//Edit button color
#define CTLCOLOR_DLG 4//Edit dialog box color
#define CTLCOLOR_SCROLLBAR 5//scroll bar
#define Ctlcolor_static 6//Edit static text color
#define CTLCOLOR_MAX 7
When used:
Hbrush Cctlcolordlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor)
{
Hbrush HBR = Cdialogex::onctlcolor (PDC, PWnd, nCtlColor);
TODO: Change any of the properties of the DC here
/*
if (This==pwnd->getdlgctrlid ())
{}//This should also be possible
*/
if (nCtlColor = = Ctlcolor_dlg)
{
Static CBrush BR (RGB (255, 100, 0)); Declaring static increases the life cycle
return BR; Default return Hbrush
}
if (nctlcolor==ctlcolor_static)
{
Pdc->setbkmode (TRANSPARENT); Setting the font color can also call SetTextColor ();
Static CBrush BR (RGB (255, 100, 0));
return BR;
}
TODO: If the default is not the desired brush, another brush is returned
return HBR;
}
MFC message OnCtlColor Change control color