#Template(AdiIdleWindow,'AdiTech Timer functions'),Family('ABC') #!AdiIdle.Tpw #!----------------------------------------------------------------------------- #!Template for emulation IDLE and closing window after period of inactivity #!written by Bjarne Havnen #!havnen@aditech.no #! #!AdiTech AS, 2002,2003 #!----------------------------------------------------------------------------- #Extension(ADIIdleWindow,'AdiTech''s Timerwindow emulates Idle'),Procedure #Button('Procedures to call'),Multi(%IdleProcs,%IdleProc & ' - '& %seconds),Inline #Prompt('Threaded procedure',Check),%Threaded #Prompt('Procedure',Procedure),%IdleProc #Prompt('Parameters withour ()',Expr),%Param #Prompt('Seconds between calls',Expr),%Seconds,Default(60) #Prompt('Variable to hold this timer',Field),%TimerField #Display('The variable is required if you want to display info, else I make one myself') #Display('Bjarne Havnen, 2002') #Prompt('Periodic event, no keycode check',Check),%alwaysrun #EndButton #Atstart #Declare(%Variable) #Endat #At(%DataSection) #For(%IdleProcs) #If (%TimerField) #Cycle #EndIf #Set(%Variable,%IdleProc&'Counter') %[20]Variable LONG !Counter for call to %IdleProc #EndFor #EndAt #At(%AfterWindowOpening) %Window{Prop:Timer}= 100 #EndAt #! #At(%WindowManagerMethodCodeSection,'TakeWindowEvent','(),Byte') If Event()=Event:Timer !Each second #If(Not %alwaysRun) If Keycode() !acitivity in window SetKeycode(0) !no keycode! #For(%IdleProcs) #Insert(%VariableName) Clear(%Variable) #EndFor End!If #EndIf #For(%IdleProcs) #Insert(%VariableName) %Variable+=1 #For(%Control),Where(%ControlUse=%Variable) Display(%Control) #EndFor If %Variable >= %Seconds Clear(%Variable) #Embed(%BeforeExecutePeriodicEvent,'Before executing periodic event'),%Variable #If(%Threaded) #If(%Param) Start(%IdleProc,25000,%param) #Else Start(%IdleProc) #EndIf #Else %IdleProc (%Param) #EndIf #Embed(%AfterExecutePeriodicEvent,'After executing periodic event'),%Variable End #EndFor #Embed(%AfterIncrementingCounters,'After incrementing counters') End!If #EndAt #Group(%VariableName) #Set(%Variable,%IdleProc&'Counter') #If (%TimerField) #Set(%Variable,%TimerField) #EndIf #Return #!Template for timing out windows. #Extension(ADITimeoutWindow,'close window after seconds of inactivity'),Procedure #Prompt('Number of secs before close',@N03),%Seconds,Default(10) #Prompt('For forms: Close without prompt',Check),%Noprompt #Display('If you check this, changes') #Display('will be saved without warning') #At(%AfterWindowOpening) %Window{Prop:Timer}=100 #EndAt #LocalData Timeout Long #EndLocalData #At(%WindowManagerMethodCodeSection,'TakeWindowEvent','(),Byte') If Event()=Event:Timer If Keycode() SetKeycode(0) Timeout=0 . Timeout+=1 If Timeout>%Seconds Timeout=0 #If (%NoPrompt) Post(Event:Completed) !autosaveing without confirmation or #Else Post(Event:CloseWindow) #EndIf . #For(%Control),Where(%ControlUse='Timeout') Display(%Control) #EndFor . #EndAt