Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1248671
  • 博文数量: 788
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 7005
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-19 15:52
文章存档

2017年(81)

2011年(1)

2009年(369)

2008年(337)

分类:

2008-11-18 14:50:22



由非激活状态变为激活状态是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   事件添加即可



[新闻]Google iPhone语音识别程序已经上线
博客园首页 社区 新闻频道 小组 博问 网摘 闪存
阅读(768) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~