solutions for flashing C # controls

Source: Internet
Author: User

The example in this article describes a workaround for C # control flicker. Share to everyone for your reference. The specific analysis is as follows:

If you're drawing in a form, whether it's a double-cache or not, you'll see that the image flashes constantly as it's updated, and the workaround is to add the following three lines of code to the form's constructor:

In the constructor, add the following lines below:


The code is as follows:

SetStyle (Controlstyles.userpaint, true);

SetStyle (Controlstyles.allpaintinginwmpaint, true); Erase background is forbidden.

SetStyle (Controlstyles.doublebuffer, true); Double buffering


Parameter description:

UserPaint

If true, the control draws itself rather than through the operating system. This style applies only to classes that derive from Control.

AllPaintingInWmPaint

If true, the control ignores WM_ERASEBKGND window messages to reduce flicker. The style should be applied only if the UserPaint bit is set to true.

DoubleBuffer

If true, the drawing is done in the buffer, and the result is output to the screen when finished. A double buffer prevents flicker caused by a control redraw. To fully enable double buffering, you must also set the UserPaint and AllPaintingInWmPaint style bits to true.

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
solutions for flashing C # controls

This address: http://www.paobuke.com/develop/c-develop/pbk23187.html






Related Content C # The instance code that connects to the SQL server2008 database C # simple way to get the coordinates of the mouse focus position in the full screen example C # in the method of exporting a DataTable in HTML format detailed C # TimeSpan calculation time difference (interval)
Using the Dictionary store events sample in C # and implementing custom event accessors C # instance code of the lucky draw upgrade version can be imported into the database through tabular data, lottery settings, the implementation of C # to generate a non-repeating order number in the shopping cart system C # decoding Base64 encoded binary data method

solutions for flashing C # controls

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.