截获与管理Windows的消息

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 firetoucher 的 blog

截获与管理windows的消息

 


摘 要:如何用一个程序截获管理windows的消息
关键字:windows 消息 监听 列表
类 别:系统控制
有时候我们为了多项应用而要管理windows的消息。我们怎样才能做到呢?

{ 这个例子定义的程序可以收取所有发往主窗口的消息 }

unit testeandoesta;

interface

uses
    sysutils, wintypes, winprocs, messages, classes, graphics, controls, forms, dialogs, menus;

type
   tform1 = class (tform)
   private {private declarations}
   public {public declarations}
      procedure winmsg (var msg : tmsg; var handled : boolean);

end;

var
   form1 : tform1;

implementation

{$r *.dfm}

{ 所有发送到主窗体的消息,保存在变量msg中。 }

procedure tform1.winmsg (var msg : tmsg; var handled : boolean);

begin
     if msg.message = wm_syscommand then beep;
     { 接收到消息时的通知}

end;

procedure tform1.formcreate (sender : tobject);

begin
     application.onmessage := winmsg;
    { 替换消息句炳}

end;

本文关键:截获与管理
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top