Programming C# C++ (7) Delphi (618) .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) Java (8) JavaScript (29) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
How can terminate my application if idle for 5 minutes?
3 comments. Current rating: (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
procedure DoOnIdle(Sender: TObject; var Done:
Boolean);
public
end;
var
Form1: TForm1;
implementation
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:
|
|
|
|
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.
|
|
|
|
|
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 :))
|
|
|
|
|
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?
|
|