Wm_ctlcolor The function corresponding to the message is Onctlcolor , Onctlcolor The function is prototype: Afx_msg hbrush Onctlcolor (CDC *PDC,Cwnd* Pwnd,UintNctlcolor ); Parameters PDC Yes: a pointer to the device environment. Pwnd : Specifies a specific control. Nctlcolor: Specifies the control type. The following types are available:
Ctlcolor_btnButton ControlCtlcolor_dlgDialog BoxCtlcolor_editEdit Control
Ctlcolor_listboxList boxCtlcolor_msgboxMessage Box
Ctlcolor_scrollbarScroll barCtlcolor_staticStatic text, frame, or rectangle
To highlight the display Number of the text box, we set the text background to yellow.
Procedure 1 Add a member variable Hbrush m_hbrush;
Procedure 2 , Use Class Wizard Is Cguessdlg Join Wm_ctlcolor Message, and edit Onctlcolor Function:
HbrushCguessdlg: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
If (nctlcolor = ctlcolor_edit)
{PDC-> setbkcolor (RGB (255,255, 0); // EditControl text background is yellow
Return m_hbrush;
}
Return cdialog: onctlcolor (PDC, pwnd, nctlcolor );
}
Compile and run. All text in the text box is yellow