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