The Parent Talks to Its Child

Although BTNLOOK does not demonstrate this fact, a window procedure can also send messages to the child window control. Five button-specific messages are defined in WINDOWS.H; each begins with the letters ”BM,“ which stand for ”button message.“ These messages are defined in WINDOWS.H in terms of the WM_USER identifier:

#define BM_GETCHECK (WM_USER+0)

#define BM_SETCHECK (WM_USER+1)

#define BM_GETSTATE (WM_USER+2)

#define BM_SETSTATE (WM_USER+3)

#define BM_SETSTYLE (WM_USER+4)

The WM_USER identifier is available for programs to define their own messages beyond the predefined messages. Each window class can have its own separate set of messages unique to that class. The other classes of predefined child window controls also can have their own messages defined in terms of WM_USER.

The BM_GETCHECK and BM_SETCHECK messages are sent by a parent window to a child window control to get and set the check mark of check boxes and radio buttons. The BM_GETSTATE and BM_SETSTATE messages refer to the normal or ”pushed“ state of a window when you click it with the mouse or press it with the Spacebar. We'll see how these messages work when we look at each type of button. The BM_SETSTYLE message lets you change the button style after the button is created.