WM_PAINT messages are generated when the window is redrawn, and when the window is redrawn (asynchronously working, more efficient, more flexible)

Source: Internet
Author: User

Q:wm_paint the message is generated when the window is redrawn, when will the window be redrawn??

A:

Strictly speaking, the window is redrawn only when the WM_PAINT message is received
But there are many events that have caused the news,
Like what:

First created
Move
Change size

Showwindow/activate window/invalidate window ....

Why is the system not sending WM_PAINT messages when calling invalidate? Why do I have to wait until the app message queue is empty to send WM_PAINT messages? This is because the system treats the drawing operations in the window as a low-priority operation, so as to be pushed backwards as much as possible. However, this also helps to improve the efficiency of drawing: Two WM_PAINT messages between the InvalidateRect and Invaliatergn to invalidate the area will be added up, and then in a WM_PAINT message is updated once, It not only avoids updating the same area multiple times, but also optimizes the app's update operations.

such as this through InvalidateRect and invalidatergn to make the window area invalid, dependent on the system. The mechanism of sending WM_PAINT messages at the right time is actually an asynchronous way of working, i.e. there is a delay between the invalid window area and the sending WM_PAINT message;

Sometimes this delay is not what we want, and of course we can use SendMessage to send a WM_PAINT message after the invalid window area to force an immediate redraw, but instead of using Windows GDI provides us with more convenient and powerful functions: UpdateWindow and RedrawWindow. UpdateWindow checks the window's update region to send the WM_PAINT message when it is not empty; RedrawWindow gives us more control: whether to redraw non-client areas and backgrounds, whether to always send WM_PAINT messages regardless of the update Whether the region is empty or not.

Http://baike.baidu.com/view/1988590.htm

WM_PAINT messages are generated when the window is redrawn, and when the window is redrawn (asynchronously working, more efficient, more flexible)

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.