Date: 02-16-2022
Return to Index
created by gbSnippets
'Credit: PIerre Bellisle
http://www.powerbasic.com/support/pbforums/showthread.php?t=14000
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
%IDC_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, %IDC_Button, "Push", 20,20,50,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static iResult,iTimer,iCount As Long
Select Case Cb.Msg
Case %WM_CtlColorBtn
If (SendMessage(GetDlgItem(hDlg,%IDC_Button),%BM_GetState,0,0) And %BST_Pushed) Then
'button down
If iTimer = 0 Then SetTimer(hDlg, %ID_Timer, 100, ByVal %NULL) : iTimer = 1
Else
'button up
If iTimer = 1 Then KillTimer hDlg, %ID_Timer : iTimer = 0 : iCount = 0
End If
Case %WM_Timer
Incr iCount
If iCount > 5 Then 'delay of 5 timer intervals to allow for normal click
'this Is where repetitive action goes
Dialog Set Text hDlg, Str$(iCount)
End If
Case %WM_Destroy
KillTimer hDlg, %ID_Timer
End Select
End Function
'gbs_01171
'Date: 03-25-2
http://www.garybeene.com/sw/gbsnippets.htm