c# - Managed form as child of unmanaged HWND -


i need show system.windows.forms.form child window of unmanaged c++ hwnd. c# sdk code retrieves nativewindow:

public static nativewindow mainwindow() {   diagnostics.process process = diagnostics.process.getcurrentprocess();   if (null == process)     return null;   intptr handle = process.mainwindowhandle;   if (intptr.zero == handle)     return null;    nativewindow wnd = new nativewindow();   wnd.assignhandle(handle);    return wnd; } 

this how implemented in plug-in:

iwin32window rh_wnd = rhino.rhinoapp.mainwindow(); doceditor.show(rh_wnd); 

this works.... of time. fails first time call code:

hwnd error http://www.freeimagehosting.net/uploads/f29bc27823.png

call again, works fine. what's going on?!?

possibly because rh_wnd null? there atleast 2 cases return null mainwindow(). might idea check

iwin32window rh_wnd = rhino.rhinoapp.mainwindow(); if ( rh_wnd != null )    doceditor.show(rh_wnd); 

and if above stops errors, might want check of above conditions returns null, , go there.

hope helps.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -