C # doublebuffered

Source: Internet
Author: User

If you draw images in the form, no matter whether the dual cache is used or not, you will see that the images will continuously flash during update, the solution is to add the following three lines of code to the constructor of the form:
 
 
 Add the following lines to the constructor:
 Setstyle (controlstyles. userpaint,True );
 Setstyle (controlstyles. allpaintinginwmpaint,True );//Do not erase background.
 Setstyle (controlstyles. doublebuffer,True );//Double Buffering
 
 Parameter description:
 
 Userpaint
 IfTrue, the control will be drawn by itself, rather than by the operating system. This style applies only to derived fromControl.
 
 Allpaintinginwmpaint
 IfTrue, the control will ignoreWm_erasebkgndWindow message to reduce flickering. Only whenUserpaintBitTrueThe style must be applied.
 
 Doublebuffer
 IfTrue, it is drawn in the buffer. After the result is finished, it is output to the screen. The dual buffer can prevent flickering caused by control re-painting. To fully enable double buffering, you must alsoUserpaintAndAllpaintinginwmpaintSet the style bitTrue.
 
 
 References:
 How to solve the problem of animation flash in CSHARP?
 Http://search.csdn.net/Expert/topic/1488/1488888.xml
 C # Implementation of Double Cache plotting.
 Http://blog.joycode.com/ghj/archive/2004/01/03/10543.aspx
 
 The above is not a drawing on the form. You need to write a control yourself and add the above three lines of code to the constructor of the control.

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.