Skip to main content

Posts

Showing posts with the label Dialog Color

How to change the background color of an MFC edit control

I am sure that many of you might thought to change the background color of Edit Control and Dialog. So i present you sample article which servers your purpose. To change the background color of an edit control in an MFC application, you must override the OnCtlColor() message-handling function of the window containing the edit control. In the new OnCtlColor() function, set the background color and return a handle to a brush that will be used for painting the background. This must be done in response to receiving both the CTLCOLOR_EDIT and CTLCOLOR_MSGBOX messages in the OnCtlColor() function. This is also documented in the "Class Library Reference" under CWnd::OnCtlColor(). Look at sample source code: // editdlg.h : header file // //////////////////////////////////////////////////////////////////////// /// // CEditDialog dialog class CEditDialog : public CDialog { // Construction public: CEditDialog(CWnd* pParent = NULL); ...