全部博文(788)
分类:
2008-11-18 14:50:22
FormDeactivate
FormDeactivate的触发时机:
when the form transitions from being the active form to another form in the same application becoming the active form.
特别说明:
If activation goes to another application, this event is not triggered.
处理办法:
To determine if another application has become active, Use the TApplication object's OnDeactivate event.
--------------------------------------------------
1、
procedure OnLoseFocus(Sender: TObject);
begin
Form1.Caption := FormatDateTime('HH:MMMM:SS', Now);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
......
@Application.OnDeactivate := @OnLoseFocus;
......
end;
2、可以捕获WM_KillFocus来处理失去焦点的事件
procedure TForm1.NewWindowProc(var Message: TMessage);
begin
if Message.Msg = WM_KillFocus then
Caption := FormatDateTime('HH:MMMM:SS', Now);
OldWindowProc(Message);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
......
OldWindowProc := sELF.WindowProc;
Self.WindowProc := NewWindowProc;
......
end;
不好意思,上次给的事件必须是在进程内部的
按照你的意思
你可以添加 ApplicationEvents 控件
然后在OnDeactivate 事件添加即可