Groups | Blog | Home
all groups > dotnet interop > october 2005 >

dotnet interop : C++ Windows Handles From C#


Robert Jordan
10/14/2005 12:00:00 AM
Hi,

[quoted text, click to view]

This is probably not an interop issue. Window handles get
sometimes recreated by WinForms. Is the window already visible
when you pass its handle to the C++ DLL?

PleaseHelp
10/14/2005 5:28:09 AM
I have an app which creates a window and C# and needs to pass the
window handle (HWND) and App Instance (HINSTANCE) to a C++ dll
whicj will do some direct show stuff. I have created the C++ MFC app and
pass the
window.Handle (System.IntPtr)

There is a wrapper which looks like:
[ DllImport("vpCSILib.dll")]
public static extern void setWnd(System.IntPtr wnd);

the c++ prototype is:
__declspec(dllexport) void CvpCSILibApp::setWnd(HWND win);

the method does
HWND m_hwndHandle=win;

sometimes it works. most time not, get a System.NullRefernceException in the
c++ dll though the pointer has a value going in. For giggles, I set managed
extentions on to debug from the c# and the win value is unused.

I haven't tied the HINSTANCE yet...
Any thoughts?

OBTW c++ is a shared MFC dll with a def file
setWnd @1
tx
PleaseHelp
10/14/2005 6:05:05 AM
Yes,
I've tried in the Load Event and after the load event by pressing a button.
assuming some wired windows re-architecture. I have even waited so that any
meesage pump handling should have been completed. But both fail mostly...



[quoted text, click to view]
AddThis Social Bookmark Button