关于WM_CTLCOLORDLG消息的处理,用来设置对话框的背景颜色,一般采用在WinnApp中使用void SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192), COLORREF clrCtlText = RGB(0, 0, 0) )实现,可是在VC2008中已经不支持这个函数,而采用在每个对话框中对WM_CTLCOLORDLG消息处理,但是实现起来非常有讲究。必须手工进行消息映射。
在VC6.0 MSDN中的关于WM_CTLCOLORDLG消息的描述如下:
WM_CTLCOLORDLG
The WM_CTLCOLORDLG message is sent to a dialog box before the system draws the dialog box. By responding to this message, the dialog box can set its text and background colors by using the given display device context handle.
WM_CTLCOLORDLG hdcDlg = (HDC) wParam; // handle of dialog box display context hwndDlg = (HWND) lParam; // handle of dialog box
Parameters
- hdcDlg
- Value of wParam. Identifies the device context for the dialog box. hwndDlg
- Value of lParam. Identifies the dialog box.
Return Values
If an application processes this message, it must return the handle of a brush. The system uses the brush to paint the background of the dialog box.