Default Button Behavior

Following are the messages processed by the predefined button-control window class (WC_BUTTON). Each message is described in terms of how a button control responds to that message.

┌─────────────────────────┬───────────────────────────────────┐
│Message                  │Description                        │
├─────────────────────────┼───────────────────────────────────┤
│BM_AUTOSIZE              │Causes the buttons in a new-style  │
│                         │notebook to automatically size to  │
│                         │fit their contents.                │
├─────────────────────────┼───────────────────────────────────┤
│BM_CLICK                 │Sends a WM_BUTTON1DOWN and         │
│                         │WM_BUTTON1UP message to itself to  │
│                         │simulate a user button selection.  │
├─────────────────────────┼───────────────────────────────────┤
│BM_QUERYCHECK            │Returns the checked state of the   │
│                         │button.                            │
├─────────────────────────┼───────────────────────────────────┤
│BM_QUERYCHECKINDEX       │Returns the 0-based index to the   │
│                         │selected button in a group.        │
│                         │Returns -1 if no button in the     │
│                         │group is selected or if the button │
│                         │receiving the message is not a     │
│                         │radio button or an auto-radio      │
│                         │button.                            │
├─────────────────────────┼───────────────────────────────────┤
│BM_QUERYHILITE           │Returns the highlighted state of   │
│                         │the button.                        │
├─────────────────────────┼───────────────────────────────────┤
│BM_SETCHECK              │Sets the checked state of the      │
│                         │button and returns the previous    │
│                         │checked state.                     │
├─────────────────────────┼───────────────────────────────────┤
│BM_SETDEFAULT            │Sets the default button state and  │
│                         │redraws the button.                │
├─────────────────────────┼───────────────────────────────────┤
│BM_SETHILITE             │Sets the highlighted state of the  │
│                         │button and returns the previous    │
│                         │highlighted state.                 │
├─────────────────────────┼───────────────────────────────────┤
│WM_BUTTON1DBLCLK         │Highlights the button and sends a  │
│                         │BN_DBLCLICKED notification code    │
│                         │when the button-up message arrives.│
├─────────────────────────┼───────────────────────────────────┤
│WM_BUTTON1DOWN           │Sets the button window so it can   │
│                         │capture mouse input.               │
├─────────────────────────┼───────────────────────────────────┤
│WM_BUTTON1UP             │If the button window is set to     │
│                         │capture mouse input, and if the    │
│                         │mouse pointer is inside the button │
│                         │window when the mouse button is    │
│                         │released, this message releases the│
│                         │mouse and sends a notification     │
│                         │message to the owner window. If the│
│                         │button is a push button, the push  │
│                         │button control posts a WM_COMMAND  │
│                         │message; otherwise, the button     │
│                         │control sends a WM_CONTROL message │
│                         │with the BN_CLICKED notification   │
│                         │code.                              │
├─────────────────────────┼───────────────────────────────────┤
│WM_CHAR                  │Sets the button window so it can   │
│                         │capture mouse input when the       │
│                         │spacebar is pressed; releases the  │
│                         │mouse when the spacebar is         │
│                         │released.  Passes other key        │
│                         │messages to the default window     │
│                         │procedure.                         │
├─────────────────────────┼───────────────────────────────────┤
│WM_CREATE                │Validates the requested button     │
│                         │style and sets the window text.    │
├─────────────────────────┼───────────────────────────────────┤
│WM_DESTROY               │Frees the memory containing the    │
│                         │window's text.                     │
├─────────────────────────┼───────────────────────────────────┤
│WM_ENABLE                │Sent when an application changes   │
│                         │the enabled state of a window.     │
├─────────────────────────┼───────────────────────────────────┤
│WM_MATCHMNEMONIC         │Returns TRUE if mp1 matches a      │
│                         │mnemonic in the control window's   │
│                         │text.                              │
├─────────────────────────┼───────────────────────────────────┤
│WM_MOUSEMOVE             │Sets the default mouse pointer.  If│
│                         │the button has the mouse captured, │
│                         │the button's highlighted state     │
│                         │changes as the mouse pointer moves │
│                         │in and out of the button boundary. │
├─────────────────────────┼───────────────────────────────────┤
│WM_PAINT                 │Draws the button according to its  │
│                         │style and current state.           │
├─────────────────────────┼───────────────────────────────────┤
│WM_QUERYDLGCODE          │Returns the DLGC_BUTTON code       │
│                         │combined with other DLGC_ codes    │
│                         │that designate the button's type.  │
├─────────────────────────┼───────────────────────────────────┤
│WM_QUERYWINDOWPARAMS     │Returns the requested window       │
│                         │parameters.                        │
├─────────────────────────┼───────────────────────────────────┤
│WM_SETFOCUS              │Creates a cursor if the            │
│                         │button-control window is receiving │
│                         │the focus.  Destroys the cursor if │
│                         │the button-control window is losing│
│                         │the focus.                         │
├─────────────────────────┼───────────────────────────────────┤
│WM_SETWINDOWPARAMS       │Sets the requested window          │
│                         │parameters and redraws the button, │
│                         │including the cursor, if the       │
│                         │button-control window has the      │
│                         │focus.                             │
└─────────────────────────┴───────────────────────────────────┘


[Back: Button Styles]
[Next: Button Notification Messages]