Date: 02-16-2022
Return to Index
created by gbSnippets
'Run button click code run as though the user had pressed the button
'Works by sending a message to the button, using %BM_CLICK
'Primary Code:
Control Post hDlg, %ID_BTN1, %BM_CLICK, 0, 0
'Compilable Example: (Jose Includes)
'Push Button#1 to see the effect. Don't press Button#2
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push1", 30,10,100,20
Control Add Button, hDlg, 200,"Push2", 30,50,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
MsgBox "Push1 ... about to click Push2 for you!"
Control Send hDlg, 200, %BM_CLICK, 0, 0
End If
If CB.Msg = %WM_Command AND CB.Ctl = 200 AND CB.Ctlmsg = %BN_Clicked Then
MsgBox "I'm Button2. You didn't push me, but I felt a click!"
End If
End Function
'gbs_00108
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm