Mi sono da poco registrato e saluto tutti, ho cercato nelle FAQs di risolvere il problema della chiusura automatica dell'applicazione lasciata aperta o inattiva da un certo tempo (in rete) dall'utente, poichè devo aprire in exclusive le tabelle del DataBase per l'indicizzazione e il PACK. In merito ho preso in considerazione i seguente codice :
How do I auto release or shut application on inactivity ? by ramani
faq184-4467
Posted: 21 Nov 03 (Edited 21 Nov 03)
**********************************************************
* Author : Ramani (Subramanian.G)
* FoxAcc Software / Winners Software
* Type : Freeware with reservation to Copyrights
* Warranty : Nothing implied or explicit
***********************************************************
** How to AutoClose a form or application.
**
#IF .f. && Just to avoid explanations from being run
* 1. Add this Timer class definition at the end of your Main.Prg
*
* Timer Class to shutdown
* Set the interval as half of inactivity time
* i.e. if you want to shut in 10 minutes of inactivity
* set timer interval as (5 Min * 60 Sec * 1000 milli)
DEFINE CLASS ShutTimer AS Timer
Interval = 10 * (60*1000/2) && 10 minutes
Name = "ShutTimer1"
PROCEDURE Init
IF VARTYPE(ptLastUsed) = "U"
PUBLIC ptLastUsed
ENDIF
m.ptLastUsed = DATETIME()
ON KEY LABEL MOUSE m.ptLastUsed = DATETIME()
ENDPROC
PROCEDURE Timer
IF ( DATETIME()- m.ptLastUsed )*1000 > This.Interval * 2
* ThisForm.Release && if only form to be released
DO myShutDown && if application to be shutdown
ENDIF
ENDDEFINE
** Enddefine
**************************************************
* 2. ADD in the KeyPress Event of the form..
m.ptLastUsed = DATETIME()
**************************************************
* 3. Set the forms property KeyPreview = .t.
**************************************************
* 4. Add the following code in the Init of the form.
WITH ThisForm
.AddObject("oTimer","Timer")
ENDWITH
**************************************************
* 5. Add a myShutDown procedure to the end of Main.Prg
PROCEDURE myShutDown
CLEAR EVENTS
QUIT
**************************************************
** 6. Add the follwoing code at the beginning of your Main.PRG
ON SHUTDOWN DO myShutDown
**************************************************
#ENDIF && end of explanations
**************************************************
Non riesco ad utilizzarlo in una normale FORMS mia tipo CLIENTI o all'avvio dell'applicazione in fase di autenticazione dell'utente.
Grazie per eventuali suggerimenti o indicazioni.
How do I auto release or shut application on inactivity ? by ramani
faq184-4467
Posted: 21 Nov 03 (Edited 21 Nov 03)
**********************************************************
* Author : Ramani (Subramanian.G)
* FoxAcc Software / Winners Software
* Type : Freeware with reservation to Copyrights
* Warranty : Nothing implied or explicit
***********************************************************
** How to AutoClose a form or application.
**
#IF .f. && Just to avoid explanations from being run
* 1. Add this Timer class definition at the end of your Main.Prg
*
* Timer Class to shutdown
* Set the interval as half of inactivity time
* i.e. if you want to shut in 10 minutes of inactivity
* set timer interval as (5 Min * 60 Sec * 1000 milli)
DEFINE CLASS ShutTimer AS Timer
Interval = 10 * (60*1000/2) && 10 minutes
Name = "ShutTimer1"
PROCEDURE Init
IF VARTYPE(ptLastUsed) = "U"
PUBLIC ptLastUsed
ENDIF
m.ptLastUsed = DATETIME()
ON KEY LABEL MOUSE m.ptLastUsed = DATETIME()
ENDPROC
PROCEDURE Timer
IF ( DATETIME()- m.ptLastUsed )*1000 > This.Interval * 2
* ThisForm.Release && if only form to be released
DO myShutDown && if application to be shutdown
ENDIF
ENDDEFINE
** Enddefine
**************************************************
* 2. ADD in the KeyPress Event of the form..
m.ptLastUsed = DATETIME()
**************************************************
* 3. Set the forms property KeyPreview = .t.
**************************************************
* 4. Add the following code in the Init of the form.
WITH ThisForm
.AddObject("oTimer","Timer")
ENDWITH
**************************************************
* 5. Add a myShutDown procedure to the end of Main.Prg
PROCEDURE myShutDown
CLEAR EVENTS
QUIT
**************************************************
** 6. Add the follwoing code at the beginning of your Main.PRG
ON SHUTDOWN DO myShutDown
**************************************************
#ENDIF && end of explanations
**************************************************
Non riesco ad utilizzarlo in una normale FORMS mia tipo CLIENTI o all'avvio dell'applicazione in fase di autenticazione dell'utente.
Grazie per eventuali suggerimenti o indicazioni.