Broad Network


Windows Button Messages

Windows Predefined Controls – Part 11

Volume - Windows User Interface

Forward: In this part of the series, we look at Windows Button Messages.

By: Chrysanthus Date Published: 29 Aug 2012

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: The 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

Related Courses

C++ Course
Relational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message