![]() |
![]() |
|
![]() |
Timeouts With Your Program © 2003 Mike Irwin Introduction Sometimes you want to clear off a form from the screen if the user just forgets about it and leaves. This example (see PR_TimeOutControl.fsl in the zip file of the same name) works when a Paradox application is left uppermost on the screen. If Paradox does not have focus then it will not work - sorry ! Globals and Constants siGTimerCounter smallInt ;......incremented every coTimerDelay milliseconds siGTimeOutCounter smallInt ;......incremented when siGTimerCounter reaches coTimerLimit loGRunTimer Logical coTimerDelay = 1000 ;1 minute ;......delay between siGTimerCounter increments coTimerLimit = 180 ;3 minutes ;......limit to value of siGTimerCounter coTimeOutLimit = 3 ;nine minutes ;......limit to value of siGTimeOutCounter The Control Just a Graphic with a nice image. The basic idea is that we have a timer that counts up to siGTimerCounter. To allow a little more flexibility, we allow ourselves to do this more than once (in fact, coTimeOutLimit times). Once we've done it that often, we close the form. Paradox is nice in that another MDI child will then get focus; if they're all equipped with this control then the forms will cascade out and finally close the application completely. This is the code in the timer() event: method timer(var eventInfo TimerEvent) ;.............always add to the "not touched" timer. siGTimerCounter = siGTimerCounter + 1 ;.............if we're over the "fine" limit then if siGTimerCounter >= coTimerLimit then ;.............reset the fine timer to start over siGTimerCounter = 0 ;.............and increment the "coarse" timer siGTimeOutCounter = siGTimeOutCounter + 1 ;.............Now, if we're also over the coarse limit, it's time to get out of here ! if siGTimeOutCounter > coTimeOutLimit then closeButton.pushButton() ;see code below for closeButton else if loGRunTimer then ;not over coarse limit so set the timer again bmpTimer.setTimer(coTimerDelay, False) endif endif else ;not over fine limit so set timer again if loGRunTimer then bmpTimer.setTimer(coTimerDelay, False) endif endif fldTimer'value = siGTimerCounter endMethod The Other Code closeButton::pushButton()All forms should have a "close" or "exit" button or method which is executed whenever the form closes. In this case hardly anything is required, but with a form where editable data is displayed the code here will have to post the record and shut the current editing session before returning control from the form. #formData1::keyPhysical() method keyPhysical(var eventInfo KeyEvent) ;Every time a key is pressed, restart the two timers if eventInfo.isPreFilter() then siGTimerCounter = 0 siGTimeOutCounter = 0 else endIf endMethod #formData1::mouseClick() method mouseClick(var eventInfo MouseEvent) ;Every time the mouse is clicked, restart the two timers if eventInfo.isPreFilter() then siGTimerCounter = 0 siGTimeOutCounter = 0 else endIf endMethod #formData1::removeFocus() method removeFocus(var eventInfo Event) ; Don't keep counting when another MDI child of Paradox has focus if eventInfo.isPreFilter() then loGRunTimer = False else endIf endMethod #formData1::setFocus() method setFocus(var eventInfo Event) ; This form has focus, so allow counting ; Assume that returning to Paradox counts as using the application loGRunTimer = True siGTimerCounter = 0 siGTimeOutCounter = 0 bmpTimer.setTimer(coTimerDelay, False) endMethod Discussion of this article |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 09 Jun 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|