G
Guest
Hello,
I have a windows application written in vb.net that involves a
treecontrol on the
left triggering the loading of forms on the right of the screen. However
there is a lot of flickering of the forms when loading. The code I have
attached deals
with a lot of the building of controls, however how do I stop the background
from
re-painting itself on loading. I am using the Office 2003 styles and when I
load my
forms you can distinctly see the forms changing colour from grey to blue,
which is
annoying for the users. Is there anyway of stopping the background colour
from
displaying until it is fully formed and so there will be less flickering.
Thanx in advance
Robert
Private _backBuffer As Bitmap
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
End If
Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
g.Dispose()
'Copy the back buffer to the screen
e.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
End Sub 'OnPaint
'base.OnPaint (e); //optional but not recommended
Protected Overrides Sub OnPaintBackground(ByVal pevent As
PaintEventArgs)
End Sub 'OnPaintBackground
'Don't allow the background to paint
Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
If Not (_backBuffer Is Nothing) Then
_backBuffer.Dispose()
_backBuffer = Nothing
End If
MyBase.OnSizeChanged(e)
End Sub 'OnSizeChanged
I have a windows application written in vb.net that involves a
treecontrol on the
left triggering the loading of forms on the right of the screen. However
there is a lot of flickering of the forms when loading. The code I have
attached deals
with a lot of the building of controls, however how do I stop the background
from
re-painting itself on loading. I am using the Office 2003 styles and when I
load my
forms you can distinctly see the forms changing colour from grey to blue,
which is
annoying for the users. Is there anyway of stopping the background colour
from
displaying until it is fully formed and so there will be less flickering.
Thanx in advance
Robert
Private _backBuffer As Bitmap
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
End If
Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
g.Dispose()
'Copy the back buffer to the screen
e.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
End Sub 'OnPaint
'base.OnPaint (e); //optional but not recommended
Protected Overrides Sub OnPaintBackground(ByVal pevent As
PaintEventArgs)
End Sub 'OnPaintBackground
'Don't allow the background to paint
Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
If Not (_backBuffer Is Nothing) Then
_backBuffer.Dispose()
_backBuffer = Nothing
End If
MyBase.OnSizeChanged(e)
End Sub 'OnSizeChanged