windows_programming_notes.nbk: Home | Index | Next Page: WM_CTLCOLORDLG | Previous Page: WM_CTLCOLOR


 WM_CTLCOLORBTN

The WM_CTLCOLORBTN message is sent to the parent window of a button before drawing the button. The parent window can change the button's text and background colors. However, only owner-drawn buttons respond to the parent window processing this message.

Parameters

Return Value

If an application processes this message, it must return a handle to a brush. The system uses the brush to paint the background of the button.

Remarks

By default, the DefWindowProc function selects the default system colors for the button. Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight, and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button.

The WM_CTLCOLORBTN message is never sent between threads. It is sent only within one thread.

The text color of a check box or radio button applies to the box or button, its check mark, and the text. The focus rectangle for these buttons remains the system default color (typically black). The text color of a group box applies to the text but not to the line that defines the box. The text color of a push button applies only to its focus rectangle; it does not affect the color of the text.

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.

Notification Requirements


windows_programming_notes.nbk: Home | Index | Next Page: WM_CTLCOLORDLG | Previous Page: WM_CTLCOLOR


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time