Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

cast to __nogc pointer from IntPtr

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dirk - 14 Jul 2004 00:51 GMT
Hello

I override the WndProc method of a control-derived class and want to handle
the WM_NOTIFY message. The following code leads to a NMHDR pointer that
points to something where all members are shown as undefined in the
debugger.

NMHDR __nogc *pnmh = static_cast<NMHDR __nogc*>(msg->LParam.ToPointer());

if I redefine NMHDR as a __gc struct and do the following everything works

gc_NMHDR __gc *pnmh = __try_cast<gc_NMHDR
__gc*>(Marshal::PtrToStructure(msg->LParam, __typeof(gc_NMHDR)));

now pnmh points to struct with valid members. PtrToStructure's purpose is it
to get the data from the unmanaged heap to the managed heap. Why does the
first method fail then?
I'd like to avoid redefining the native structs and want to use the first
method.

Thanks
Tomas Restrepo \(MVP\) - 14 Jul 2004 03:12 GMT
Dirk,

> I override the WndProc method of a control-derived class and want to handle
> the WM_NOTIFY message. The following code leads to a NMHDR pointer that
[quoted text clipped - 11 lines]
> to get the data from the unmanaged heap to the managed heap. Why does the
> first method fail then?

Is it *actually* failing? So far, all you've said is the debugger can't
display it, but have you actually checked you can't access its values?

I ask this because there are some well-known issues with the debugger with
mixed-mode debugging (heck, even the managed mode debugger gets stuck
sometimes)...

Signature

Tomas Restrepo
tomasr@mvps.org

dirk - 14 Jul 2004 09:38 GMT
Hello

No, it does not fail. Although shown as undefined comparison and
modification work. I had some other issues during my first tries that
prevented the WM_NOTIFY I was interested in from being sent. Some WM_NOTIFY
messages were sent, but because I could not easily check which one I changed
different things. So I am glad that I can use the native structs.

Thanks

> Dirk,
>
[quoted text clipped - 4 lines]
> mixed-mode debugging (heck, even the managed mode debugger gets stuck
> sometimes)...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.