Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timing out
Message
From
29/05/1998 16:50:44
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00100666
Message ID:
00103243
Views:
50
Thanks!!! Your was a lot more involved than mine!

Trish


>>>>
>>>>Could you email me the code? trishm@sccsi.com.
>>>>
>>>>I want the system to shut down. I have too many people here that leave with their system running and then I can't put out a new EXE. I am also going to use WINBATCH to copy it to their local drive after a time and date stamp check.
>>>>
>>>>Thanks.
>>>>
>>>>Trish
>>>
>>>Trish,
>>>
>>>I received an e-mail request for the code the other day which I responded to. Was it you? I do not recall and do not have access to my e-mail at the moment.
>>
>>
>>No it wasn't me. I have implemented something but I would like to see if you have something better.
>>
>>Thanks.
>>
>>Trish
>
>Trish,
>
>Here's the code:
>
>
**************************************************
>*-- Class:        tmrtimeout (d:\clients\investlink\tsm50\libs\apptimeout.vcx)
>*-- ParentClass:  timer
>*-- BaseClass:    timer
>*
>DEFINE CLASS tmrtimeout AS timer
>
>
>	Height = 23
>	Width = 23
>	*-- The amount of time to timeout on
>	ntimeout = 0
>	*-- Time this program last ran (in seconds)
>	nlastrun = 0
>	*-- Time the program detected the last change in state
>	nlastchange = 0
>	*-- Last mouse column detected
>	nlastmousecol = 0
>	*-- Last mouse row detected
>	nlastmouserow = 0
>	*-- Current mouse column
>	nmousecol = 0
>	*-- Current Mouse Row
>	nmouserow = 0
>	*-- Current Time the timer ran in calctime() format
>	nrun = 0
>	*-- Current active form.
>	cactiveform = ("")
>	*-- Active form at the last timer run
>	clastactiveform = ("")
>	*-- Value of LastKey() when timer is run.
>	nkey = 0
>	*-- Lastkey pressed by the user at the  previous timer run.
>	nlastkey = 0
>	Name = "tmrtimeout"
>
>
>	*-- Calculates time in seconds. Not the SECONDS() function.
>	PROCEDURE calctime
>		LPARAMETERS tcTime
>
>		IF PCOUNT() =0
>			tcTime = Time()
>		ENDIF
>
>		#DEFINE SECONDS_DAY		86400
>		#DEFINE SECONDS_HOUR	3600
>		#DEFINE SECONDS_MINUTE	60
>		#DEFINE ELAPASED_DAYS	DATE() - {01/01/97}
>		#DEFINE ELAPSED_HOURS
>
>		*-- This function will return seconds since 1/1/97. This way, when we move from
>		*-- one day to another (which would cause Seconds() to recycle to 0), we are
>		*-- not affected.
>		*--
>		*-- One other point. I am trying to optimize the code as much as possible because this
>		*-- timer may run many times in a session and I want it to be unnoticeable.
>		LOCAL lnDays, lnHours, lnMinutes, lnSeconds, lnRetVal
>
>		lnDays = DATE() - {01/01/97}
>		lnHours = VAL(LEFT(tcTime,2))
>		lnMinutes = VAL(SUBST(tcTime,4,2))
>		lnSeconds = VAL(SUBST(tcTime,7))
>
>		lnRetVal = (lnDays * SECONDS_DAY) + ;
>					(lnHours * SECONDS_HOUR) + ;
>					(lnMinutes * SECONDS_MINUTE) + ;
>					lnSeconds
>
>		RETURN lnRetVal
>	ENDPROC
>
>
>	*-- Timeout the application
>	PROCEDURE timeoutapp
>		LOCAL loTimeoutForm, llUserCancel
>		loTimeOutform = CREATEOBJECT("timeoutform")
>		loTimeOutform.Show()
>
>		llUserCancel = loTimeoutForm.uRetVal
>		loTimeoutForm.Release()
>
>		IF !llUserCancel
>			ON SHUTDOWN
>			IF TYPE("goAPP") == "O" AND !ISNULL(goAPP)
>				*-- Cancel everything out there...
>
>				LOCAL lnForm
>
>				*-- Loop through all open forms and request that they be closed
>				lnForm = 1
>				FOR lnForm = 1 TO _screen.FormCount
>					IF TYPE("_screen.Forms(lnForm)") == "O" AND !ISNULL(_screen.Forms(lnForm))
>						IF UPPER(_screen.Forms(lnForm).BaseClass) = "TOOLBAR"
>							LOOP
>						ENDIF
>
>						IF PEMSTATUS(_screen.Forms(lnForm), "Cancel", 5)
>							_screen.Forms(lnForm).Cancel()
>						ENDIF
>					ENDIF
>				ENDFOR
>				goAPP.CleanUp()
>			ENDIF
>
>			QUIT
>		ELSE
>			*-- If the user cancels the timeout, reset the timer counter
>			this.nLastChange = this.nRun
>		ENDIF
>	ENDPROC
>
>
>	PROCEDURE Timer
>		LOCAL llChange, lnInterval
>
>		WITH this
>			*-- Turn the timer off while we are in the timer event
>			lnInterval= .Interval
>			.Interval = 0
>
>			.nRun = .CalcTime()
>			.nMouseCol = MCOL("")
>			.nMouseRow = MROW("")
>			.nKey = LASTKEY()
>			.cActiveForm = IIF(TYPE("_screen.activeform.caption") == "C", ;
>									_screen.activeform.caption, ;
>									"***DESKTOP***")
>
>			llChange = !(.nKey = .nLastKey ;
>							AND .nMouseCol = .nLastMouseCol ;
>							AND .nMouseRow = .nLastMouseRow ;
>							AND .cActiveForm == .cLastActiveForm)
>
>			*-- Now, if we have a change, just record it and go on
>
>			IF llChange
>				.nLastChange = .nRun
>			ELSE
>				IF .nRun - .nLastChange >= .nTimeOut
>					*-- Timeout
>					.TimeOutApp()
>				ENDIF
>			ENDIF
>
>			*-- Save the current state
>
>			.nLastRun = .nRun
>			.nLastMouseCol = .nMouseCol
>			.nLastMouseRow = .nMouseRow
>			.nLastKey = .nKey
>			.cLastActiveForm = .cActiveForm
>
>			*-- And that's that
>			.Interval = lnInterval
>		ENDWITH
>	ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: tmrtimeout
>**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform