窗体form失去焦点时(非激活状态),发生什么事件

窗体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   事件添加即可

转载于:https://www.cnblogs.com/delphi2007/archive/2008/11/18/1335909.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值