Hello,
I am trying to use an MFC/Direct Draw based DLL in my c# application. It is not a COM control but rather creates a CWindow based object to perform it's rendering on. It should essentially acted like a panel, or picture box that I would be able to put in a tabpage.
The interface to this DLL is a few simple C style entry points including a "create_window" type function. This function takes a window handle as the parent window for the new window.
I have a simple static c# class that uses p/invoke to call directly into this entry point. I use it like this:
FancyPInvoke.createWindow(this.tabPage1.Handle);
My problem is I can't seem to create a valid parent handle for my dll. Inside the dll if I use something like the following everything works (however, I get some disjoint window that isn't part of my app :( )
create_cwnd(hParentFromPInvoke, WS_POPUPWINDOW|WS_THICKFRAME);
My problem is when I try to create a window that will "sit" in a panel in my app.
create_cwnd(hParentFromPInvoke, WS_CHILD | WS_VISIBLE );
dfsadfdfsacreate_wnd boils down to doing a MFC createEx call using AfxRegisterWndClass.
When I get to this point in the code using the child option the app throws an exception in afxwin2.inl which is basically telling me that my window handle is invalid (fails on assert IsWindow()).
Thanks in advance for your help and patience - wasn't sure where best to post this.
Chris

MFC CWindow Handles in C#