A
Able
Dear friends
I have some drawing commands in the Form1_paint
event. It works pretty well. The drawing gets
redrawn when the window is resized. It gets redrawn after I minizie the
window and bring it back. But when I bring another application to the
foreground and drag it across my graphics window or let my window come to
foreground again the program crashes.
This errormsg occurs at "Public Class Form1":
An unhandled exception of
type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an
instance of an object
Here is the Form1_paint routine:
Dim gb As New Drawing2D.LinearGradientBrush( _
New Rectangle(0, 0, Form1.ActiveForm.Width, Form1.ActiveForm.Height), _
Color.White, Color.Yellow, 10 _
)
gb.SetSigmaBellShape(0.9)
e.Graphics.FillRectangle( _
gb, _
0, _
0, _
Form1.ActiveForm.Width, _
Form1.ActiveForm.Height _
)
Somebody knows what is wrong?
Regards Able
I have some drawing commands in the Form1_paint
event. It works pretty well. The drawing gets
redrawn when the window is resized. It gets redrawn after I minizie the
window and bring it back. But when I bring another application to the
foreground and drag it across my graphics window or let my window come to
foreground again the program crashes.
This errormsg occurs at "Public Class Form1":
An unhandled exception of
type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an
instance of an object
Here is the Form1_paint routine:
Dim gb As New Drawing2D.LinearGradientBrush( _
New Rectangle(0, 0, Form1.ActiveForm.Width, Form1.ActiveForm.Height), _
Color.White, Color.Yellow, 10 _
)
gb.SetSigmaBellShape(0.9)
e.Graphics.FillRectangle( _
gb, _
0, _
0, _
Form1.ActiveForm.Width, _
Form1.ActiveForm.Height _
)
Somebody knows what is wrong?
Regards Able