Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_Timer = 500
Global hDlg As Dword
Function PBMain () As Long
Dialog New Pixels, 0, "Timer",,, 200,100, %WS_OverlappedWindow To hDlg
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static iCount As Long
Select Case Cb.Msg
Case %WM_LButtonDown
SetTimer(Cb.Hndl, %ID_Timer, 100, ByVal %NULL) 'uses callback messages
Case %WM_LButtonUp
KillTimer Cb.Hndl, %ID_Timer
Case %WM_Timer
‘this is where repetitive action goes
Incr iCount
Dialog Set Text hDlg, Str$(iCount)
End Select
End Function
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword, OldProc&
%ID_Button = 500
%ID_Timer = 501
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %ID_Button, "Push", 20,20,50,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static iCount As Long
Select Case Cb.Msg
Case %WM_InitDialog
OldProc& = SetWindowLong(GetDlgItem(hDlg, %ID_Button), %GWL_WndProc, CodePtr(NewProc)) 'subclass
Case %WM_Destroy
KillTimer hDlg, %ID_Timer
SetWindowLong GetDlgItem(hDlg, %ID_Button), %GWL_WNDPROC, OldProc& 'un-subclass
Case %WM_Timer
'this Is where repetitive action goes
Incr iCount
If iCount > 5 Then Dialog Set Text hDlg, Str$(iCount)
End Select
End Function
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case %WM_LButtonDown
SetTimer(hDlg, %ID_Timer, 100, ByVal %NULL) 'uses callback messages
Case %WM_LButtonUp
KillTimer hDlg, %ID_Timer
End Select
Function = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
End Function
'gbs_01169
'Date: 03-25-2
http://www.garybeene.com/sw/gbsnippets.htm