C # How to Handle control flashing,

Source: Internet
Author: User

C # How to Handle control flashing,

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); // The background cannot be erased.
SetStyle (ControlStyles. DoubleBuffer, true); // Double Buffer

Parameter description:

UserPaint
If it is true, the control will be drawn by itself, rather than by the operating system. This style applies only to classes derived from Control.

AllPaintingInWmPaint
If true, the control ignores the WM_ERASEBKGND window message to reduce flickering. This style should be applied only when the UserPaint bit is set to true.

DoubleBuffer
If this parameter is set to true, the image is drawn in the buffer and the result is output to the screen. The dual buffer can prevent flickering caused by control re-painting. To fully enable double buffering, you must also set the UserPaint and AllPaintingInWmPaint style bits to true.

Related Article

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.