21:23 2005-12-8
1.变体记录
type
TMessage=packed record//Using packed slows data access and, in the case of a character array,
affects type compatibility (for more information,
msg:Cardinal;
case Integer of
0:(
WParam:Longint;
LParam:Longint;
Result:LongInt;
);
1:(
WParamLo:word;
WParamHi:word;
LParamLo:word;
LParamHi:word;
ResultLo:word;
ResultHi:word;
);
end;
以上是vcl消息定义
typedef struct {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG, *PMSG;
系统消息结构定义
2.vcl中两种消息派遣
vcl消息机制的整个流程如下:
Windows->Delphi Application->(TWinControl)MainWndProc->WndProc->Dispatch->Handler
(1)Application->dispatchMessage(const lpMsg:TMsg)根据参数lpMsg的接受者句柄字段,将消息正文发给
该句柄对应的窗口控件在windows中注册的窗口过程:Twincontrol.MainWndProc.所以到这里,消息就传递给
Twincontrolle了。这是在Windows中派遣,是底层Api函数的调用。
(2)TObject.Dispatch(var Message);
Dispatch首先在本类中查找相应的消息方法,如果没有找到,那么逐级上溯父类,祖先类,直到找到对应的
消息方法。
procedure Tobject.Dispatch(var Message)
begin
搜索Handler;
如果没有找到就调用DefaultHandler(var Message);
end;
你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=3826873