WM_CTLCOLORSTATIC

A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control.

WM_CTLCOLORSTATIC 
hdcStatic = (HDC) wParam;   // handle to display context 
hwndStatic = (HWND) lParam; // handle to static control 
 

Parameters

hdcStatic
Value of wParam. Handle to the device context for the static control window.
hwndStatic
Value of lParam. Handle to the static control.

Return Values

If an application processes this message, the return value is a handle to a brush that the system uses to paint the background of the static control.

Default Action

The DefWindowProc function selects the default system colors for the static control.

Remarks

Edit controls that are not read-only or disabled do not send the WM_CTLCOLORSTATIC message; instead, they send the WM_CTLCOLOREDIT message. However, for compatibility purposes, the system sends the WM_CTLCOLOREDIT message for read-only and disabled edit controls if the application was designed for Windows 3.1 or earlier.

The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.

The WM_CTLCOLORSTATIC message is never sent between threads; it is sent only within the same thread.

If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. If the dialog box procedure returns FALSE, then default message handling is performed. The DWL_MSGRESULT value set by the SetWindowLong function is ignored.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 2.0 or later.
  Header: Declared in winuser.h.

See Also

Static Controls Overview, Static Control Notification Messages, DefWindowProc, RealizePalette, SelectPalette, WM_CTLCOLORBTN, WM_CTLCOLORDLG, WM_CTLCOLOREDIT, WM_CTLCOLORLISTBOX, WM_CTLCOLORMSGBOX, WM_CTLCOLORSCROLLBAR