windows消息的结构
TMsg = packed record
hwnd: HWND;//窗口句柄
message: UINT;//消息标识
wParam: WPARAM;//
lParam: LPARAM;//
time: DWORD;//消息创建的时间
pt: TPoint;//消息创建时鼠标所在位置
end;
WM_KEYDOWN,WM_KEYUP, WM_KEYPRESS: KEYPress消息不同之处在于只有对应有ascii码的按键才会产生这个消息
windows消息流程
1.系统中产生事件
2.windows把这个事件翻译成消息,并放入消息队列
3.应用程序从消息队列中接收到这个消息,把它放到TMsg记录中
4.应用程序把消息传递给一个适当的窗口的窗口过程
5.窗口过程响应这个消息并处理
步骤3,4就构成了应用程序的消息循环。
delphi把windows的TMsg记录中的信息映射为TMessage记录:
TMessage = record
Msg: Cardinal;
case Integer of
0:( WParam: LongInt;
LParam: LongInt;
Result: LongInt);
1:( WParamLo: Word;
WParamHi: Word;
LParamLo: