Home All Groups Group Topic Archive Search About

convert class instance to IntPtr

Author
7 Aug 2006 3:29 PM
swartzbill2000
I want to PostMessage from a class instance to its containing form. I
want the WPARAM to point to the class instance. I am using the
declaration of PostMessage from www.pinvoke.net. WPARAM is an IntPtr.
VB2005 won't let me do this:
CType(Me, IntPtr)
How can I pass Me as the WPARAM arg?
Bill

Author
7 Aug 2006 8:19 PM
Mythran
<swartzbill2***@yahoo.com> wrote in message
news:1154964568.151460.99710@i3g2000cwc.googlegroups.com...
>I want to PostMessage from a class instance to its containing form. I
> want the WPARAM to point to the class instance. I am using the
> declaration of PostMessage from www.pinvoke.net. WPARAM is an IntPtr.
> VB2005 won't let me do this:
> CType(Me, IntPtr)
> How can I pass Me as the WPARAM arg?
> Bill
>

Might be able to use System.Runtime.InteropServices.Marshal methods to get
the interface you need.

Maybe Marshal.GetIDispatchForObject?

HTH,
Mythran
Author
7 Aug 2006 9:00 PM
swartzbill2000
I found GCHandle. It works.
Bill
Mythran wrote:
Show quoteHide quote
> <swartzbill2***@yahoo.com> wrote in message
> news:1154964568.151460.99710@i3g2000cwc.googlegroups.com...
> >I want to PostMessage from a class instance to its containing form. I
> > want the WPARAM to point to the class instance. I am using the
> > declaration of PostMessage from www.pinvoke.net. WPARAM is an IntPtr.
> > VB2005 won't let me do this:
> > CType(Me, IntPtr)
> > How can I pass Me as the WPARAM arg?
> > Bill
> >
>
> Might be able to use System.Runtime.InteropServices.Marshal methods to get
> the interface you need.
>
> Maybe Marshal.GetIDispatchForObject?
>
> HTH,
> Mythran