In Windows, messages use a uniform structure body (MSG) to hold information, where message indicates the specific type of messages,
And Wparam,lparam is the most flexible of the two variables, for different message types, the meaning of storing data is not the same.
Time indicates when the message was generated, and PT indicates the position of the mouse at the time the message was generated.
There is no option for result. Then I measured the size of the MSG structure with VC2008:
#include <afx.h>void Cxe111dlg::onbnclickedbutton1 () { CString m_str; int sizeof (MSG); M_str.format (_t ("%d"), DDD); AfxMessageBox (M_STR);}
Result equals 28
void Cxe111dlg::onbnclickedbutton1 () { CString m_str; int sizeof (wm_size); M_str.format (_t ("%d"), DDD); AfxMessageBox (M_STR);}
Result equals 4
void Cxe111dlg::onbnclickedbutton1 () { CString m_str; int sizeof (WM_CHAR); M_str.format (_t ("%d"), DDD); AfxMessageBox (M_STR);}
Result equals 4
-------------------------------------------------------------
Then look at the definition of Delphi, it also has the original model is defined, but generally not used:
PMSG = ^tmsg; packed Record Hwnd:hwnd; message : UINT; Wparam:wparam; Lparam:lparam; Time:dword; Pt:tpoint; End ; = tagmsg; = Tagmsg;
After testing, its size is of course 28:
procedure Tform1.button3click (sender:tobject); begin showmessage (inttostr (sizeof (TAGMSG))); End;
Then look at the message structure that Delphi really uses, and note that it includes the result:
PMessage = ^tmessage; packed Record msg:cardinal; Case of 0 : ( wparam:longint; Lparam:longint; Result:longint); 1 : ( Wparamlo:word; Wparamhi:word; Lparamlo:word; Lparamhi:word; Resultlo:word; Resulthi:word); End;
To test its size:
procedure Tform1.button3click (sender:tobject); begin showmessage (inttostr (sizeof (tmessage))); End;
Result equals 16
-------------------------------------------------------------
Re-test the size of the message itself:
procedure Tform1.button3click (sender:tobject); begin showmessage (inttostr (sizeof (WM_CHAR))); End;
Result equals 2
procedure Tform1.button3click (sender:tobject); begin showmessage (inttostr (sizeof (wm_size))); End;
Result equals 1
-------------------------------------------------------------
Then look at the message structure of Delphi definition:
Twmsize =packed Recordmsg:cardinal; Sizetype:longint; {size_maximized, size_minimized, size_restored, Size_maxhide, Size_maxshow}Width:word; Height:word; Result:longint; End; Twmkey=packed Recordmsg:cardinal; Charcode:word; Unused:word; Keydata:longint; Result:longint; End; Twmchar=Twmkey; Twmpaint=packed Recordmsg:cardinal; DC:HDC; Unused:longint; Result:longint; End; Twmcommand=packed Recordmsg:cardinal; Itemid:word; Notifycode:word; Ctl:hwnd; Result:longint; End; Twmnotify=packed Recordmsg:cardinal; Idctrl:longint; NMHDR:PNMHDR; Result:longint; End;
To test the size of the Delphi message structure:
procedure Tform1.button3click (sender:tobject); begin showmessage (inttostr (sizeof (twmsize))); ShowMessage (IntToStr (sizeof (Twmchar))); ShowMessage (IntToStr (sizeof (twmpaint))); ShowMessage (IntToStr (sizeof (Twmcommand))); ShowMessage (IntToStr (sizeof (twmnotify))); End;
How to measure all is 16 bytes size ...
Finally understand: Delphi message result is completely sporogenous out, not the Windows message comes with (Delphi on the Windows programming system, the larger the transformation, the greater the learning harvest)