I checked the message processing mechanism today. To prevent future forgetting, I wrote my understanding into my blog.
1. First, any message is transmitted to the operating system, and then the operating system delivers the message to the message queue.
2. In the message queue, extract the message with getmessage () and send it to the application based on the order and weight of the message.
3. After the message is obtained, the application will first perform some preprocessing, for example, discard the response of some messages or call translatemessage () to generate a new message. As for why the function is called, the function is mainly used to process the key information we input. Every time we press a character key, wm_keydown and wm_ketup messages are generated. These two messages contain some additional parameters wparam and lparam, when processing a message, we need to convert the information into wm_char information, which is the role of the translatemessage () function. Information processed by translatemessage () generates new information and is returned to the message queue.
4. pre-processed information will be sent to the operating system through dispathmessage (), and finally the operating system will send the information to the corresponding form function.