How can I avoid the fliker of a form?
-
Maybe because I used too many controls,my application has the phenomenon of flicker.I used SetStyle function like this: this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); but it seems no use. how can I avoid it?
-
Maybe because I used too many controls,my application has the phenomenon of flicker.I used SetStyle function like this: this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); but it seems no use. how can I avoid it?
according to the documentation you should call UpdateStyles() after setting the style bits :)
Luc Pattyn
-
according to the documentation you should call UpdateStyles() after setting the style bits :)
Luc Pattyn
I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }
-
I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }
You've said your Form has a huge number of controls on it. Maybe you should do double buffer on the controls too.
-
I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }
Hi, In my applications, I usually use LPW_DoubleBufferedPanel instances, where LPW_DoubleBufferedPanel simply inherits from Panel, while setting the three style bits in its constructor (the SetStyle method is protected, so you can not call it from outside the panels). using System; using System.Windows.Forms; namespace LP_Basics { //################################################################################ /// /// LPW_DoubleBufferedPanel is a panel that uses double buffering to avoid flicker. /// //################################################################################ [System.ComponentModel.DesignerCategory("Code")] public class LP_DoubleBufferedPanel : Panel { /// /// Construct a double buffered Panel. /// public LP_DoubleBufferedPanel() { // set 3 bits to get double buffering SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true); SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,true); SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true); } } } (remark: I don't need the UpdateStyles method here since the Panel's handle has not been created yet, so the panel is born with the new style settings). Following your mail, I have tried SetStyles on a form, and it does not work the way you and I would hope. It seems the double buffering characteristic is not inherited by its children. So I suggest you start using LPW_DoubleBufferedPanel and the like. I admit, if you need a lot of different kinds of Controls, this may become cumbersome. :(
Luc Pattyn