BM_GETCHECK Message

Platforms

Description & Usage

Sending the BM_GETCHECK message to a button determines if that button is currently checked. Obviously, this message only works with buttons that are check boxes or radio boxes.

Return Value

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

BST_CHECKED
The button is checked.
BST_INDETERMINATE
The button is grayed, in an indeterminate state. This only works with check boxes that have three possible states.
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_GETCHECK = &HF0
Const BST_CHECKED = &1
Const BST_INDETERMINATE = &2
Const BST_UNCHECKED = &0

Example

Use the BM_GETCHECK message to determine the checked status 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_GETCHECK = &HF0
Public Const BST_CHECKED = &1
Public Const BST_INDETERMINATE = &2
Public Const BST_UNCHECKED = &0

' *** Place the following code inside the form window. ***
Private Sub Command1_Click()
	Dim state As Long  ' checked state of the check box
	
	' Find the checked state of Check1 and tell the user what it is.
	state = SendMessage(Check1.hWnd, BM_GETCHECK, ByVal CLng(0), ByVal CLng(0))
	Select Case state
	Case BST_CHECKED
		Debug.Print "The check box is checked."
	Case BST_INDETERMINATE
		Debug.Print "The check box is in its third state (grayed)."
	Case BST_UNCHECKED
		Debug.Print "The check box is not checked."
	End Select
End Sub

See Also

BM_GETSTATE, BM_SETCHECK

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_getcheck.html