WM_CTLCOLOR

This message is sent to the parent window of a predefined control or message box when the control or message box is about to be drawn. By responding to this message, the parent window can set the text and background colors of the child window by using the display-context handle given in the wParam parameter.

Parameter Description  

wParam Contains a handle to the display context for the child window.  
lParam The low-order word of the lParam parameter contains the handle to the child window. The high-order word is one of the following values, specifying the type of control:  
  Value Control Type
  CTLCOLOR_BTN Button control
  CTLCOLOR_DLG Dialog box
  CTLCOLOR_EDIT Edit control
  CTLCOLOR_LISTBOX List-box control
  CTLCOLOR_MSGBOX Message box
  CTLCOLOR_SCROLLBAR Scroll-bar control
  CTLCOLOR_STATIC Static control

Default Action

The DefWindowProc function selects the default system colors.

Comments

When processing the WM_CTLCOLOR message, the application must align the origin of the intended brush with the window coordinates by first calling the UnrealizeObject function for the brush, and then setting the brush origin to the upper-left corner of the window.

If an application processes the WM_CTLCOLOR message, it must return a handle to the brush that is to be used for painting the control background. Note that failure to return a valid brush handle will place the system in an unstable state.