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] "Robert Jordan" wrote:
> Hi,
>
> > 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.
>
> 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?
>
> Rob