Flicker problem !!!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All:),
I have Form with BackgroundImage, in my form i have 20
controls(labels,buttons ...)
But controls refreshing too slow(like flicker).

thanks in advance
 
Hi,
Does SetStyle(ControlStyles.DoubleBuffer, true); alleviate the problem?
Also ee can increase the rendering speed dramatically by caching this brush
and painting Form's background ourselves like the following:

Dim backBrush As TextureBrush = Nothing

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles MyBase.Load

Dim backImage As Bitmap = Nothing
backImage = Me.Panel1.BackgroundImage
Me.Panel1.BackgroundImage = Nothing
backBrush = New TextureBrush(backImage, Drawing2D.WrapMode.Tile)
End Sub


Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles MyBase.Closed
If Not backBrush Is Nothing Then
backBrush.Dispose()
End If
End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
If (Not backBrush Is Nothing) Then
e.Graphics.FillRectangle(backBrush, e.ClipRectangle)
End If
End Sub
 
You should put it in the New() subroutine, AFTER calling
InitializeComponents().
Hope this helps.
VBen.
 
Yes I use,
I made own label and i added in constructor:
class Label_me : Label
{
public Label_me();
{
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
}
}
I try with redefine Form like Libel_me, and I try with PictureBox but the
result is same:((
 
Yes I use,
I made own label and i added in constructor:
class Label_me : Label
{
public Label_me();
{
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
}
}
I try with redefine Form like Libel_me, and I try with PictureBox but the
result is same:((
 
Thanks Andy:)
after I use:
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
If (Not backBrush Is Nothing) Then
e.Graphics.FillRectangle(backBrush, e.ClipRectangle)
End If
End Sub
I think now it works good:)
 
Back
Top