Form里面有什么事件(50分)

Z

zwwhb

Unregistered / Unconfirmed
GUEST, unregistred user!
程序要实现这样一个功能,当没人使用程序超过一定时间时,自动调用登陆窗体,应该是使用什么事件,或者其他的什么方法
 
使用TTimer定时器呀,呵呵
Form是没有定时功能的
 
用Timer控件
 
程序要检测一段时间里面有没有人动过电脑,象系统的屏幕保护功能一样的
 
>>要检测一段时间里面有没有人动过电脑
如果只是自己的程序,用TTimer;
如果是要判断整个Windows,用Hook
 
hook怎么用,我不知道
 
截获键盘、鼠标消息
多长时间没人动就触发登陆窗口procedure TForm1.ApplicationEventsMessage(var Msg: tagMSG;
var Handled: Boolean);
begin
//如果已经定义主系统的Application的OnMessage事件则先调用;
//处理键盘、鼠标消息
if ((Msg.message >= WM_KEYFIRST) and (Msg.message <= WM_KEYLAST)) or
((Msg.message >= WM_MOUSEFIRST) and (Msg.message <= WM_MOUSELAST))then
LastActTime := now;
end;

procedure TForm1.TimerTimer(Sender: TObject) ;
begin
//如果键盘、鼠标在指定的时间内没有消息,调用处理事件
if SecondsBetween(now,LastActTime) > IdleTimeLimited then
begin
LastActTime := now;
ShowMessage('本程序未活动时间超过'+IntToStr(IdleTimeLimited)+'秒!');
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
LastActTime := now;
IdleTimeLimited := 3;
Oclock := TTimer.Create(self);
Oclock.Enabled := True;
//设置时间控件的时间事件
Oclock.OnTimer := TimerTimer;
Application.OnMessage := ApplicationEventsMessage;

end;

 
谢谢落木萧萧
 
顶部