DelphiFAQ Home Search:

How can terminate my application if idle for 5 minutes?

 

comments3 comments. Current rating: 5 stars (2 votes). Leave comments and/ or rate it.

Question:

How can terminate my application if idle for 5 minutes?

Answer:

This should get you started. For testing I set the timer to 10 seconds.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    procedure DoOnIdle(Sender: TObject; var Done:
Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.DoOnIdle(Sender: TObject; var
Done: Boolean);
begin
  Timer1.Enabled := False;
  Timer1.Enabled := True;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnIdle := DoOnIdle;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  ShowMessage('Shutdown!');
end;

end.

Comments:

2006-08-11, 03:04:00
anonymous from Turkey  
rating
thanks for your effort and this nice result. It was very useful for me. I think more people will use this in order to solve their problems for automatic-termination of their programs.
2006-10-31, 07:03:12
anonymous from Greece  
rating
Thanks for the idea. I made a some kind of password keeper and I need to lock the application after several minutes. Ones again - Thank you :))
2007-01-25, 03:34:17
anonymous from Indonesia  
This trick won't work if focus is inside an edit (or other keyboard input control such as TMemo). Is there any other trick to overcome this problem?

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: