通过 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.
相关文章推荐
- 学习 Message(4): 通过 Application.OnMessage 或 TApplicationEvents 响应消息
- Application.OnMessage 或 TApplicationEvents 响应消息 (转自:万老师的博客)
- 判断软件的闲置时间(使用Application.OnMessage过滤所有键盘鼠标消息)
- 消息函数响应的添加(ON_MESSAGE的用法)
- 通过TApplicationEvents响应消息
- 对话框不响应WM_KEYDOWN消息,可以通过重载BOOL PreTranslateMessage(MSG * pMsg)来实现
- VC自定义消息ON_MESSAGE的编译错误error C2440
- MFC对话框禁止移动 使标题栏不响应鼠标消息 通过客户区移动窗体 OnNcHitTest()的实现
- 无法分析从服务器收到的消息。之所以出现此错误,常见的原因是: 在通过调用 Response.Write() 修改响应时,将启用响应筛选器、HttpModule 或服务器跟踪。
- 重写PreTranslateMessage(MSG* pMsg)遇到的问题--相应右键消息。隔一次响应一次,求解。
- OCX控件响应PreTranslateMessage消息的步骤
- PreTranslateMessage无法捕获WM_VSCROLL 滑动条添加消息响应
- MFC ON_UPDATE_COMMAND_UI消息不响应
- Windows消息响应机制之四:PostQuitMessage和GetMessage函数 .
- 学习 Message(5): 关于 TApplicationEvents.OnMessage 的第二个参数
- 通过Html5的postMessage和onMessage方法实现跨域跨文档请求访问
- 响应ON_NCPAIT消息
- 如何使得OCX控件能响应PreTranslateMessage消息?
- vs2005 添加 OnTimer 消息响应
- 提升Web Services性能原来不是通过传说中的压缩Soap请求和响应消息来实现的