Button Default Message Processing

The window procedure for the predefined button control window class carries out default processing for all messages that the button control procedure does not process. When the button control procedure returns FALSE for any message, the predefined window procedure checks the messages and performs the default actions listed in the following table.

Message Default action
BM_CLICK Sends the button a WM_LBUTTONDOWN and a WM_LBUTTONUP message, and sends the parent window a BN_CLICKED notification message.
BM_GETCHECK Returns the check state of the button.
BM_GETIMAGE Returns the handle of the bitmap or icon associated with the button or NULL if the button has no bitmap or icon.
BM_GETSTATE Returns the current check state, push state, and focus state of the button.
BM_SETCHECK Sets the check state for all styles of radio buttons and check boxes. If the wParam parameter is greater than zero for radio buttons, the button is given the WS_TABSTOP style.
BM_SETIMAGE Associates the specified bitmap or icon handle with the button and returns the handle of the previous bitmap or icon.
BM_SETSTATE Sets the push state of the button. For owner-drawn buttons, a WM_DRAWITEM message is sent to the parent window if the state of the button has changed.
BM_SETSTYLE Sets the button style. If the low-order word of the lParam parameter is TRUE, the button is redrawn.
WM_CHAR Checks a check box or automatic check box when the user presses the plus (+) or equal (=) keys. Unchecks a check box or automatic check box when the user presses the minus (-) key.
WM_ENABLE Paints the button.
WM_ERASEBKGND Erases the background for owner-drawn buttons. The backgrounds of other buttons are erased as part of the WM_PAINT and WM_ENABLE processing.
WM_GETDLGCODE Returns values indicating the type of input processed by the default button procedure, as shown in the following table.

Button style Returns
BS_AUTOCHECKBOX  
  DLGC_WANTCHARS | DLGC_BUTTON
BS_AUTORADIOBUTTON  
  DLGC_RADIOBUTTON
BS_CHECKBOX  
  DLGC_WANTCHARS | DLGC_BUTTON
BS_DEFPUSHBUTTON  
  DLGC_DEFPUSHBUTTON
BS_GROUPBOX  
  DLGC_STATIC
BS_PUSHBUTTON  
  DLGC_UNDEFPUSHBUTTON
BS_RADIOBUTTON  
  DLGC_RADIOBUTTON

WM_GETFONT Returns a handle of the current font.
WM_KEYDOWN Pushes the button if the user presses the SPACEBAR.
WM_KEYUP Releases the mouse capture for all cases except the TAB key.
WM_KILLFOCUS Removes the focus rectangle from a button. For push buttons and default push buttons, the focus rectangle is invalidated. If the button has the mouse capture, the capture is released, the button is not clicked, and any push state is removed.
WM_LBUTTONDBLCLK Sends a BN_DBLCLK notification message to the parent window for radio buttons and owner-drawn buttons. For other buttons, a double-click is processed as a WM_LBUTTONDOWN message.
WM_LBUTTONDOWN Highlights the button if the position of the mouse cursor is within the button's client rectangle.
WM_LBUTTONUP Releases the mouse capture if the button had the mouse capture.
WM_MOUSEMOVE Performs the same action as WM_LBUTTONDOWN, if the button has the mouse capture. Otherwise, no action is performed.
WM_NCCREATE Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
WM_NCHITTEST Returns HTTRANSPARENT, if the button control is a group box.
WM_PAINT Draws the button according to its style and current state.
WM_SETFOCUS Draws a focus rectangle on the button getting the focus. For radio buttons and automatic radio buttons, the parent window is sent a BN_CLICKED notification message.
WM_SETFONT Sets a new font and optionally updates the window.
WM_SETTEXT Sets the text of the button. In the case of a group box, the message paints over the preexisting text before repainting the group box with the new text.
WM_SYSKEYUP Releases the mouse capture for all cases except the TAB key.

The predefined window procedure passes all other messages to the DefWindowProc function for default processing.