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 in-depth Understanding C # Boxing and unpacking (finishing) C # WX's basic approach to obtaining tokens C#url action class encapsulation, copying URL module instances in node. js, using the const and readonly modifiers in C #
C # using chained methods to express loops nesting new keywords for C # fundamentals Introduction to C # How to generate DLL files summary C # method for simple screen monitoring
solutions for flashing C # controls