Invalidate and Flicker
-
I am trying to create a VB.NET smooth progress bar custom control that also displays the percent in the middle. To prevent flicker I calculate the part of the control rectangle that has changed when the progress value is updated. To force the text in the middle to also be updated I also calculate a second rectangle that bounds the text. Then I call Invalidate method using the Union method with the two rectangles - the progress bar rectangle and the text rectangle. This works fine and does not flicker until the progress rectangle reaches the text rectangle. Once it reaches the text rectangle, and at all points even after it passes the text rectangle, there is flicker. Any suggestions??
-
I am trying to create a VB.NET smooth progress bar custom control that also displays the percent in the middle. To prevent flicker I calculate the part of the control rectangle that has changed when the progress value is updated. To force the text in the middle to also be updated I also calculate a second rectangle that bounds the text. Then I call Invalidate method using the Union method with the two rectangles - the progress bar rectangle and the text rectangle. This works fine and does not flicker until the progress rectangle reaches the text rectangle. Once it reaches the text rectangle, and at all points even after it passes the text rectangle, there is flicker. Any suggestions??
You can turn on double buffering for your application. this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true ); That's the C# version Christian Graus - Microsoft MVP - C++
-
You can turn on double buffering for your application. this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true ); That's the C# version Christian Graus - Microsoft MVP - C++
Thanks, that helps. I still don't understand why a region that is not invalidated would flicker, but ....