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 6 1885
Check out if the Form1.ActiveForm has a value.
if Form1.ActiveForm is nothing then
MsgBox("Blub")
end if
"Able" <ab**************@epost.no> schrieb im Newsbeitrag
news:Nt*****************@news2.e.nsc.no... 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
OK, I typed this in first of Form1_paint event
If Form1.ActiveForm Is Nothing Then
MsgBox("Blub")
End If
The message was fired before each crash But I dont understand how I can take
advantage of this.
Rgards Able
"Armin" <Ar***@humsoft.com> skrev i melding
news:bp*************@news.t-online.com... Check out if the Form1.ActiveForm has a value.
if Form1.ActiveForm is nothing then MsgBox("Blub") end if
"Able" <ab**************@epost.no> schrieb im Newsbeitrag news:Nt*****************@news2.e.nsc.no... 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
Hi Able,
Can you try it also in a simple program with only this, I cannot get your
exception.
A nice white and yellow page that I can close, minimize, hide behind another
etc.
no exception.
Framework 1.1
Cor 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 _
)
Now you know that Form1.ActiveForm is nothing.
That's the Reason why it crashes....
You can not get the Width of a Object that is not existent. Right ?
Only execute the whole Code if activeForm is not nothing
or don't use ActiveForm..... New Rectangle(0, 0, Form1.ActiveForm.Width, Form1.ActiveForm.Height),
_
"Able" <ab**************@epost.no> schrieb im Newsbeitrag
news:xK*****************@news2.e.nsc.no... OK, I typed this in first of Form1_paint event
If Form1.ActiveForm Is Nothing Then
MsgBox("Blub")
End If
The message was fired before each crash But I dont understand how I can
take advantage of this.
Rgards Able
"Armin" <Ar***@humsoft.com> skrev i melding news:bp*************@news.t-online.com... Check out if the Form1.ActiveForm has a value.
if Form1.ActiveForm is nothing then MsgBox("Blub") end if
"Able" <ab**************@epost.no> schrieb im Newsbeitrag news:Nt*****************@news2.e.nsc.no... 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
Damn. This seems to be a late evening.
Regards Able
"Cor" <no*@non.com> skrev i melding
news:uk**************@TK2MSFTNGP11.phx.gbl... Hi Able,
Can you try it also in a simple program with only this, I cannot get your exception.
A nice white and yellow page that I can close, minimize, hide behind
another etc. no exception.
Framework 1.1
Cor
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 _
)
Solved it by replacing Form1.ActiveForm with Me in Form1_paint event.
Regards Able
"Able" <ab**************@epost.no> skrev i melding
news:6W*****************@news2.e.nsc.no... Damn. This seems to be a late evening.
Regards Able
"Cor" <no*@non.com> skrev i melding news:uk**************@TK2MSFTNGP11.phx.gbl... Hi Able,
Can you try it also in a simple program with only this, I cannot get
your exception.
A nice white and yellow page that I can close, minimize, hide behind another etc. no exception.
Framework 1.1
Cor
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 _
)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tamir Khason |
last post by:
How I can paint something onClick event?
I need PaintEventArgs event in order to paint and raise Graphics, but
onClick I have only EventArgs Event...
Thanx
|
by: Duncan Mole |
last post by:
Hi,
I have created a control which draws a title bar and provides a drop down
menu for a Smart Device Application. It seemed to work fine until I came to
add an event handler to act on Paint...
|
by: WStoreyII |
last post by:
i am using this code to try to paint a line on my form and it wont work i
get an object not set to a reference error
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim...
|
by: jcrouse |
last post by:
I am rotating some text is some label controls. In the one place I use it it
works fine. In the other place I use it I can't figure out the syntax. I
don't really understand the event. Where it...
|
by: nate axtell |
last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
|
by: Aaron Smith |
last post by:
I have a panel that I have in the paint event to draw a Raised 3d border
around it.. The problem is, if a msgbox is popped up or a tooltip is
displayed, it leaves lines on the panel. I've tried...
|
by: Dennis |
last post by:
I am trying to implement drawing on a bitmap and using bitblt to transfer
it to the control graphics object in the paint event. It seems to draw on
the bitmap ok but doesn't get transferred to the...
|
by: tommaso.gastaldi |
last post by:
Hello,
A probably dumb question...
does anyone know hot to avoid that if one keep the mouse pressed on an
arrow of the numericUpDown it continues to fire events (it uses
evidently a timer) ?...
|
by: Rotsey |
last post by:
Hi,
I have a interface that I use for a form so I can pass the form
to another object.
How do I add the Paint event to the interface and subsequently
handle the paint event in my other...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |