Tuesday, December 12

Windows Button Messages

Google+ Pinterest LinkedIn Tumblr +

Windows Predefined Controls – Part 11
Volume – Windows User Interface

Introduction
This is part 11 of my series, Windows Predefined Controls. In order to understand this tutorial, you most have read all the previous tutorials of the series. In this part of the series, we look at Windows Button Messages.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

Messages
An application can send a message to a button. The button processes the message. You send such a message to a control using the SendMessage function. For details on using this function, read a tutorial of this series, titled, “Control Messages”. I now give you the message code and their meanings.

Message Code: Meaning
BM_GETCHECK: This message returns the check state of the button; this is applicable to check and radio buttons. Here, the wParam and lParam parameters are not used and must each be zero. The return value is one of the following:
BST_CHECKED: Button is checked.
BST_INDETERMINATE: Button is grayed, indicating an indeterminate state.
BST_UNCHECKED: Button is cleared
You application has to determine which of the above three values (code) has been returned (use if-construct).

BM_GETSTATE: This message returns the current check state, push state, and focus state of the button. Here, the wParam and lParam parameters are not used and must each be zero. The return code is a combination of any of the following:
BST_CHECKED: The button is checked.
BST_DROPDOWNPUSHED: The button is in the drop-down state; for Windows Vista. This applies only if the button has the TBSTYLE_DROPDOWN style.
BST_FOCUS: The button has the keyboard focus.
BST_HOT: The button is hot; that is, the mouse is hovering over it.
BST_INDETERMINATE: The state of the button is indeterminate. Applies only if the button has the BS_3STATE or BS_AUTO3STATE style.
BST_PUSHED: The button is being shown in the pushed state.
BST_UNCHECKED: No special state. Equivalent to zero.

BM_SETCHECK:  This message sets the check state for radio buttons and check boxes. The wParam can be one of the following values (code):
BST_CHECKED: Sets the button state to checked.
BST_INDETERMINATE: Sets the button state to grayed, indicating an indeterminate state. You should use this value only if the button has the BS_3STATE or BS_AUTO3STATE style.
BST_UNCHECKED: Sets the button state to cleared.
If the wParam parameter is greater than zero for radio buttons, the button is given the WS_TABSTOP style (see later).
The lParam is not used and should be NULL.
This message always returns zero.

BM_SETSTATE: This message sets the push state of the button. The pushed state affects only the appearance of the button. It has nothing to do with the check state of the button.
The wParam is a BOOL that specifies whether the button is highlighted (pushed). A value of TRUE highlights the button. A value of FALSE removes any highlighting.
The lParam is not used and should be NULL.
This message always returns zero.

BM_SETSTYLE: This message sets the button style.
The wParam parameter can be a combination of button styles.
For the lParam the LOWORD of lParam is a BOOL that specifies whether the button is to be redrawn. A value of TRUE redraws the button; a value of FALSE does not redraw the button.
This message always returns zero.

That is it for this part of the series. We stop here and continue in the next part.

Chrys

To arrive at any of the parts of this series, just type the corresponding title below in the Search Box of this page and click Search (use menu if available):

Edit Control Messages
Button Types in Windows
Uses of the Different Types of Buttons
Button Notification Messages
Windows Button Messages
A Window Button Function and Macro
Windows Static Control
 

Share.

About Author

Leave A Reply