和伟哥合作愉快- -| 回首页 | 2005年索引 | - -Delphi精要笔记 4

Delphi精要笔记 3

关键词消息                                          

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;

【作者: 阿猴】【访问统计:】【2005年12月9日 星期五 20:13】【 加入博采】【打印

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=3826873

博客手拉手

一则未经证实的消息 Doctor.Q
来了一个坏消息 听你随风
最新消息 独行侠
一些让你有感触的短消息 yanying8247
近期消息 hnust885

回复

评论内容: