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.
The BM_SETCHECK message always returns 0.
None.
Const BM_SETCHECK = &HF1
Const BST_CHECKED = &1
Const BST_INDETERMINATE = &2
Const BST_UNCHECKED = &0
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
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