Exception in VB.Net App

A

anand

Hi
Does any body know how to fix this problem. I get this when VB.Net app
uses my Active X control which is ownew Draw
Thank you
Anand


See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.NativeWindow.GetHandleFromID(Int16 id)
at System.Windows.Forms.Control.WmOwnerDraw(Message& m)
at System.Windows.Forms.Control.WmDrawItem(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
 
B

Bryan Martin

The message is telling you that whatever your calling at that point is not
an actual object. In other words make sure you have created an instance of
your object before attempting to use its methods.

Dim mobj_Object as yourobject = new yourobject
 
A

anand

Hi
Thank you for your response. But here is the full scoop.
I have written an Active X control in VC6 which sub classes a button
and I am trying to use it in Dot Net.

Everything seems fine till I change the button style to "ownerDraw". I
do that by changing a property on my control which changes the window
style of my subclassed in VC6 code. At this point the application
crashes with the following exception stack.

If I handle for Example WM_SetFocus, WM_KILLFocus and WM_PAINT then it
does not crash. But for ownerDraw buttons the control is only required
to handle WM_DRAWITEM and not all the above messages.

Either I am not setting something right or it is a Dot Net Bug.

This control works fine in VB6 and MFC

Thank you for your help.

Anand

Exception Stack.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.NativeWindow.GetHandleFromID(Int16 id)
at System.Windows.Forms.Control.WmOwnerDraw(Message& m)
at System.Windows.Forms.Control.WmDrawItem(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top