BM_SETCHECK Message

Platforms

Description & Usage

Sending the BM_SETCHECK message to a button changes the checked state of a button. Naturally, the button has to be either a check box or a radio button for the message to work. The message can check or uncheck the button. If the button is a three-state check box, the message can also put the button into its third, grayed state.

Return Value

The BM_SETCHECK message always returns 0.

Visual Basic-Specific Issues

None.

Parameters

wParam
One of the following flags specifying how to set the button's checked state:
BST_CHECKED
Check the button.
BST_INDETERMINATE
Put the button into its third, grayed state. This only works for three-state check boxes.
BST_UNCHECKED
Uncheck the button.
lParam
Not used -- set to 0.

Constant Definitions

Const BM_SETCHECK = &HF1
Const BST_CHECKED = &1
Const BST_INDETERMINATE = &2
Const BST_UNCHECKED = &0

Example

Use the BM_SETCHECK message to place a check mark inside of Check1. Do this when a button is pressed. To run this example, place a check box control named Check1 and a command button named Command1 inside a form window.

' 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_SETCHECK = &HF1
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 retval As Long  ' return value
	
	' Place a check mark inside Check1.
	retval = SendMessage(Check1.hWnd, BM_SETCHECK, ByVal CLng(BST_CHECKED), ByVal CLng(0))
	' That's it!
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_setcheck.html