Some experience in resolving the Windows program Interface flicker problem

Source: Internet
Author: User
The general Windows complex interface needs to use multiple layers of windows and be embellished with textures, so it's inevitable to flicker when the window moves or changes size.
Let's talk about the cause of the flicker.
Reason one:
If you are familiar with the graphics principle, the call to the GDI function to the screen output is not immediately displayed on the screen
is just written to the memory, and the video card every time the contents of the memory output to the screen, this is the refresh cycle.
The general video card refresh cycle is 1/80 seconds or so, the specific number can set itself.
This is the problem, general drawing is the background color first, and then the contents of the painting, if these two operations are not the same
Refresh cycle, then give people the visual feeling is, first see only the background color of the image, and then see the picture of the content,
This will feel the flicker.
Solution: As fast as possible to output the image, so that the output in a refresh cycle to complete, if the output of a lot of slow, then use
Memory buffering method, first the content to be output in memory ready, and then output to video memory. To know that an API call can generally
Completed in a refresh cycle.
For GDI, you can use the method of creating a memory DC
Reason two:
The complex interface has multiple layers of windows, when Windows changes the size of the window is the first redraw the parent window, and then redraw the child window, child parent
The process of painting a window can generally not be completed within a refresh cycle, so it renders a flicker.
We know there's no need to repaint the part of the parent window that covers the Quilt window.
Workaround: Add a style ws_clipchildren to the window so that the part of the parent window that is blocked by the quilt window will not be repaint.
If there is overlap between sibling windows, then you need to add ws_clipsiblings style
Reason three:
Sometimes you need to use some control on the window, ie, when you change the size of the window IE will blink, even if you have a Ws_clipchildren
is useless. The reason is that the class style of the window has Cs_hredraw or cs_vredraw, which means that the window changes in width or height
Repaint, but this will cause IE to blink
Workaround: Do not use these two styles when registering a window class, and if the window needs to be wm_size when the size is changed, then you can

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.