I'm trying to create and display a user control written in C# in one of our
legecy C++ apps.
Everything compiles and links fine and the managed control is being created
but there's no sign of it in the window. That is, I get no run-time errors. I
created test apps to bypass the complexities of the real classes I have to
deal with.
When I had no luck using the managed class directly through the gcroot
template I added the CWnd wrapper but it made no difference.
I'm pretty sure I'll be able to expose the managed class as an ActiveX
control and all will be OK but I'd rather avoid the extra step.
In the CView derived class I have:
gcroot<TransCore::TIS::Controls::TISList *> tisList;
CWnd * tisListWrapper;
In the View's OnInitialUpdate override:
#pragma push_macro("new")
#undef new
tisList = new TransCore::TIS::Controls::UserControlDontCheckMeIn ();
#pragma pop_macro("new")
tisListWrapper = new CWnd();
tisListWrapper->Attach ( (HWND)tisList->Handle.ToInt32() );
And in the OnSize handler:
if ( tisListWrapper != NULL )
tisListWrapper->SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_SHOWWINDOW );
--
Thanks,
Dan