定时关闭窗口(200分)

  • 主题发起人 主题发起人 高小五
  • 开始时间 开始时间

高小五

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾,在DELPHI中怎么解决这个问题:
打开一个窗口后,如果5分钟没有人操作过,则自动关闭此窗口以及上一级窗口,
并且返回到主窗体。
 
用鼠标钩子和键盘钩子,检查鼠标键盘多就没有操作了。
 
TApplicationEvents和Ttimer结合使用即可
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
Timer1.Enabled := False;
end;

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

procedure TForm1.Timer1Timer(Sender: TObject);
begin
form1.Close;
(form1.Parent as Tform).close;
end;
快试试吧
 
TApplicationEvents在additional组件中
Ttimer设interval为5*60*1000
你也可在ApplicationEvents1Message中再对消息具体进行判断和过滤处理
 
果然很好
 
做一个无模式对话框,在这个Form上放一个TTimer,在 Form的事件里做一下判断就可以了...
 
多人接受答案了。
 
后退
顶部