窗体form失去焦点时(非激活状态),发生什么事件
2008-11-18 14:21
459 查看
窗体form失去焦点时(非激活状态),发生什么事件 VCL组件开发及应用
http://www.delphi2007.net/DelphiVCL/html/delphi_20061222233159173.html
由非激活状态变为激活状态是onActivate对吧
那么由激活状态变为非激活状态则对应哪个事件呢?onDeactivate么?我试了好像没用,鼠标点桌面或其他窗口,则form窗体变为非激活,应该触发啥事件?
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 事件添加即可
http://www.delphi2007.net/DelphiVCL/html/delphi_20061222233159173.html
由非激活状态变为激活状态是onActivate对吧
那么由激活状态变为非激活状态则对应哪个事件呢?onDeactivate么?我试了好像没用,鼠标点桌面或其他窗口,则form窗体变为非激活,应该触发啥事件?
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 事件添加即可
相关文章推荐
- form表单字段元素对象实例(一)— —当将焦点切换到密码框时,密码输入框上将发生onFocus事件。
- 失去焦点和获得焦点发生事件(js)
- onblur 事件会在对象失去焦点时发生
- onblur 事件会在对象失去焦点时发生。
- winform窗体失去焦点事件
- 窗体失去焦点事件浅谈
- CListCtrl非激活状态,失去焦点依然高亮显示
- 关于窗体和控件获取与失去输入焦点的事件
- 失去焦点和获得焦点发生事件(js)
- onchange事件在失去焦点事件之后发生的问题?
- ng-blur失去焦点执行事件
- 失去焦点与点击事件冲突
- ASP.NET 文本框失去焦点事件验证用户是否已经存在
- Android中导入Unity项目,界面点击事件失去焦点问题
- 失去焦点事件 blur()
- DIV类似失去焦点事件(点击层外层隐藏)
- VB用End退出,不会发生Form_Unload事件
- ToolStrip失去焦点时,点击第二次才执行事件的解决方法
- 文本框失去焦点事件、获得焦点事件
- 获得焦点事件和失去焦点事件