Message transmission refers to the transmission of message data, and data is a group of data, so the message is a structure;
The standard message structure of the system is defined as tmsg in Delphi.
PMSG = ^ tmsg; tagmsg = packed record hwnd: hwnd; message: uint; wparam: wparam; lparam: lparam; Time: DWORD; Pt: tpoint; end; tmsg = tagmsg; MSG = tagmsg;
However, more message structures in tmsg and VCL, such as twmmouse and twmkey, are incompatible;
However, twmmouse and twmkey are both compatible: tmessage;
Tmessage is the message structure redefined by VCL:
Pmessage = ^ tmessage; tmessage = packed record MSG: Cardinal; Case integer of 0: (wparam: wparam; lparam: lparam; Result: lresult); 1: (wparamlo: word; wparamhi: word; lparamlo: word; lparamhi: word; resultlo: word; resulthi: Word); end;
How many times does it necessary for Delphi not to directly use tmsg but to have a tmessage?
What I can know now: 1. simplification; 2. Adding a return value; there must be other reasons. Please let me know first.
However, I think VCL will eventually return to the structure format of tmsg to deal with the system.
Different message parameters have different meanings;
Some parameters in different messages are meaningless and can be omitted;
In addition, some message parameters are very abstract and need to be converted repeatedly to obtain data that is easy to understand. Why not simply use data that is easy to understand?
Therefore, Delphi defines more message structures:
Queue = twmnoparams; queue = twmnoparams; twmclear = twmnoparams; twmclose = queue; twmcopy = queue; twmcut = queue; queue = queue; twmfontchange = twmnoparams; queue = twmnoparams; queue = twmnoparams; twmgethotkey = queue; queue = queue; twmmdigetactive = queue; queue = queue; twmpainticon = queue; twmpaste = twmnoparams; twmquerydragicon = queue; queue = queue; twmqueryopen = twmnoparams; queue = queue; twmsyscolorchange = queue; twmtimechange = queue; queue = queue; twmundo = twmnoparams; queue = twmkey; twmkeydown = twmkey; twmkeyup = twmkey; second = twmchar; second = twmkey; second = twmmouse; twmlbuttondown = twmmouse; second = twmmouse; twmmbuttondown = twmmouse; success = twmmouse; twmmousemove = twmmouse; success = twmmouse; twmrbuttondown = twmmouse; success = success; success = twmscroll; twmvscroll = twmscroll; items = twmchartoitem; items = plain; plain = twmctlcolor; plain = plain; twmnchitmessage; Messages = success; Messages = twmnchitmessage; twmncrbuttonup = twmnchitmessage; twmstylechanging = twmstylechange; twmupdateuistate = twmuistate; twmupdateuistate = twmprint;
The purpose of doing so is nothing more than understanding and simplicity. But why are there so many renames (indicating that their parameter structures are the same?
I think Delphi may do this to match messages one by one. For example, the wm_lbuttondown Message corresponds to the twmlbuttondown structure.
In this way, based on the naming rules, you can easily find the corresponding message structure through the message name.
Tmessage is common in VCL and can replace any of them.
In addition, will this be all Windows messages?
I don't think so. Just like API functions, they are constantly increasing. Besides, there are so many custom messages, which should be common and enough.