您的位置:首页 > 移动开发

通过 Application.OnMessage 响应消息

2010-02-14 16:00 417 查看




unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    {这个自定义过程要复合 Application.OnMessage 的参数格式}
    procedure MyMessage(var Msg: tagMSG; var Handled: Boolean);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Memo1.Clear;
  Application.OnMessage := MyMessage; {让 Application.OnMessage 执行自定义过程}
end;

{响应 WM_MOUSEMOVE 以外的所有消息}
procedure TForm1.MyMessage(var Msg: tagMSG; var Handled: Boolean);
begin
  if Msg.message <> WM_MOUSEMOVE then
    Memo1.Lines.Add('$' + IntToHex(Msg.message, 4));
end;

end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐