Windows API programming from scratch-Windows Message Processing Mechanism

Source: Internet
Author: User
Notes:

1. Message Processing Method
In Windows, messages are processed in two ways: one is to directly call wndproc using messages as parameters, and the other is to add messages to message queues.
Therefore, neither getmessage () nor peekmessage () can receive all the messages, but can only receive the messages in the message queue.
. Windows systems can call wndproc () at any time without havingProgramRequest. For example, when createwindow () is used
The wm_create message calls wndproc ....

Of course, dispatchmessage () Requests also enable Windows to call wndproc. Dispatch () will not be returned until the message processing is complete.

2. message about wm_paint
When the window is invalid, the system adds the wm_paint message to the window message queue. The message must be processed, and the window is validate after processing; otherwise, the message
It cannot be eliminated in the queue, causing the program to remain in getmessage (wm_paint), wndproc (wm_paint ),...... Another solution is
Let defwindowproc () process the wm_paint message so that the window is validated.

3. About defwindowproc ()
This function is required and automatically processes certain messages. If these messages are not correctly processed, the program may be abnormal.

4. message about wm_destroy
This message must be processed by a programmer, generally postquitmessage (0); otherwise, the startup is destroyed and the program is still running.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.