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"
%IDC_TextBox = 500
%ID_Timer = 501
Global hDlg,ghHook As Dword, Seconds As Long
Function PBMain() As Long
Dialog New Pixels, 0, "Toolbar Test",400,400,300,100, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %IDC_TextBox, "Type here to reset timer!", 10,10,220,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
ghHook = SetWindowsHookEx(%WH_Keyboard, CodePtr(KeyBoardProc), GetModuleHandle(""), GetCurrentThreadId)
SetTimer(Cb.Hndl, %ID_Timer, 1000, ByVal %NULL) '1 second intervales
Case %WM_Timer
Incr Seconds
Dialog Set Text hDlg, "Time to Logoff: " + Str$(600-Seconds) + " seconds!"
If Seconds > 600 Then
KillTimer Cb.Hndl, %ID_Timer
? "Time to logoff"
End If
Case %WM_InitDialog
Case %WM_Destroy
KillTimer Cb.Hndl, %ID_Timer
UnhookWindowsHookEx ghHook
End Select
End Function
Function KeyBoardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode < 0 Then Exit Function 'prevent from doing stuff below
Seconds = -1
Function = CallNextHookEx(ByVal ghHook, ByVal nCode, ByVal wParam, ByVal lParam)
End Function
'gbs_01299
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm