Home » Controls » How to visually click Command button through code
How to visually click Command button through code
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 'Controls - How to visually click Command button through code Option Explicit 'Add three CommandButtons to your form. 'When you press the second button, the first button will be pressed. 'When you press the third button, the first button will be released. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long Public Const BM_SETSTATE = &HF3 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Private Sub Command2_Click() Call SendMessage(Command1.hwnd, BM_SETSTATE, 1, ByVal 0&) End Sub Private Sub Command3_Click() Call SendMessage(Command1.hwnd, BM_SETSTATE, 0, ByVal 0&) End Sub |
Enjoy this article?
Filed under: Controls
Leave a comment