G
Guest
I migrated a VB6.0 application to VB.NET. This app has a drawing area, which
is a panel. The user can drag and drop several objects on this drawing area
and can also draw lines, boxes etc. The app is sufferring from the problem of
flicker.
On reading several posts on this forum and others I decided to enable double
buffering for my panel. However the drawing area appears blank. I can briefly
see the objects when adding new objects on the drawing area.
I have a context menu associated w/ the panel. On clicking the Show option
in the context menu, the drawing appears, however on resizing the form or
adding a new object to the drawing area, the screen becomes blank again.
Any idea as to what I am missing here?
Posting some code snippets below, if that will help.
Thanks in advance for your help.
Code:
'This class defines an object which is a specialized panel, which eliminates
'the flickering effect when used as a drawing pad
Public Class CBufferedPanel
Inherits Panel
Public Sub New()
MyBase.New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.DoubleBuffer Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint, _
True)
UpdateStyles()
End Sub
End Class
'In the form that has the panel, I define picSegment of type CBuffered class
and instantiate it
Public Class DrawingArea
Inherits System.Windows.Forms.Form
Private Sub picSegment_Paint(ByVal Sender As Object, ByVal pea As
PaintEventArgs) _
Handles picSegment.Paint
'Paint method calls the draw routine
DrawAll(picSegment, True)
End Sub
End Class
is a panel. The user can drag and drop several objects on this drawing area
and can also draw lines, boxes etc. The app is sufferring from the problem of
flicker.
On reading several posts on this forum and others I decided to enable double
buffering for my panel. However the drawing area appears blank. I can briefly
see the objects when adding new objects on the drawing area.
I have a context menu associated w/ the panel. On clicking the Show option
in the context menu, the drawing appears, however on resizing the form or
adding a new object to the drawing area, the screen becomes blank again.
Any idea as to what I am missing here?
Posting some code snippets below, if that will help.
Thanks in advance for your help.
Code:
'This class defines an object which is a specialized panel, which eliminates
'the flickering effect when used as a drawing pad
Public Class CBufferedPanel
Inherits Panel
Public Sub New()
MyBase.New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.DoubleBuffer Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint, _
True)
UpdateStyles()
End Sub
End Class
'In the form that has the panel, I define picSegment of type CBuffered class
and instantiate it
Public Class DrawingArea
Inherits System.Windows.Forms.Form
Private Sub picSegment_Paint(ByVal Sender As Object, ByVal pea As
PaintEventArgs) _
Handles picSegment.Paint
'Paint method calls the draw routine
DrawAll(picSegment, True)
End Sub
End Class