Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Timeout in Delphi 7

Status
Not open for further replies.

cucho

Programmer
Oct 1, 2001
15
AR
I need to set an application timeout but i don't know how to do it.
Anyone can help me.

Thanks in advance.

 
Use TTimer.

Put a TTimer on your main form, or create a data module for one.

Set TTimer.Interval to the time period you require (milliseconds).

TTimer.OnTimer event, maybe code like:
Application.Termintate

To start the timer set TTimer.Enabled := true;
To stop it before it completes set Enabled := false;

Hope this helps
Simon
 
If you want the timeout to happen after a period of days, you need to setup a counter and store this to the registry, cfg or any file, also store the first run date. Then decrement the counter every time the program runs and the date is different to that stored.
Eventually the counter will get to zero and you can terminate the application (with a suitable warning).

Note This is a simple approach and could easily be 'hacked' I use a more complex 'two tier' version of this for my apps, a date file and a registry entry which must be in sync, its still not perfect but better.



Steve: Delphi a feersum engin indeed.
 
I need to shutdown the application if the user has not use it for 30 minutes.
 
Use the TTimer as Vintagewine suggests but get it to decrement a global integer, Use the Form's onkeypress and onmouse move events to reset the global to the start value.

Start the Value at e.g 30,000 in onactivate
and set the time to a 1000 mS inteval and decrement and check the value, if it gets to zero terminate.



Steve: Delphi a feersum engin indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top