Windows API Guide: Using API Structures


Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

Sending the BM_GETSTATE message to a button retrieves information about the state of the button. This message works will all types of buttons, including command buttons, check boxes, and radio buttons.

Return Value

If an error occured, the message returns zero. Otherwise, the message returns a combination of the following values specifying the button's current state:

BST_CHECKED
The button is checked.
BST_FOCUS
The button has the keyboard focus.
BST_INDETERMINATE
The button is grayed, in an indeterminate state. This only works with check boxes that have three possible states.
BST_PUSHED
The button is being pushed. This is typically caused by the left button being held down on top of the button, making it look pushed in.
BST_UNCHECKED
The button is unchecked.

Visual Basic-Specific Issues

None.

Parameters

wParam
Not used -- set to 0.
lParam
Not used -- set to 0.

Constant Definitions

Const BM_GETSTATE = &HF2 Const BST_CHECKED = &H1 Const BST_FOCUS = &H8 Const BST_INDETERMINATE = &H2 Const BST_PUSHED = &H4 Const BST_UNCHECKED = &H0

Example

Use the BM_GETSTATE message to determine the state of check box Check1 when a button is pressed. To run this example, you need to create a check box control named Check1 and a command button named Command1 in a form window. The check box may be any type you wish.

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd _ As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long Public Const BM_GETSTATE = &HF2 Public Const BST_CHECKED = &H1 Public Const BST_FOCUS = &H8 Public Const BST_INDETERMINATE = &H2 Public Const BST_PUSHED = &H4 Public Const BST_UNCHECKED = &H0 ' *** Place the following code inside the form window. *** Private Sub Command1_Click() Dim state As Long  ' checked state of the check box ' Find the state of Check1 and tell the user what it is. state = SendMessage(Check1.hWnd, BM_GETSTATE, ByVal CLng(0), ByVal CLng(0)) If state And BST_CHECK Then Debug.Print "The check box is checked." ElseIf state And BST_INDETERMINATE Then Debug.Print "The check box is in its third state (grayed)." Else Debug.Print "The check box is not checked." End If If state And BST_FOCUS Then Debug.Print "The check box has the keyboard focus." If state And BST_PUSHED Then Debug.Print "The check box is being pushed." End Sub

See Also

BM_GETCHECK, BM_SETSTATE

Category

Buttons

Back to the Function list.
Back to the Reference section.


Last Modified: July 30, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/b/bm_getstate.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net