views:

43

answers:

1

Hi,

I've developed a c# control, and I can reuse this in other c# apps and that works really well.

However I want to host this control in a Win32 c++ app, is there a way to do this?

I was wondering if it would work with managed c++, however I can't quite figure out if this is possible.

Any help would be gratefully received.

Cheers Rich

+1  A: 

You can use the Com Interop Toolkit to solve this.

This is how I do it: I create my control in C# When I want to expose this control to another Win32 app, I expose this control via com. I create a new project using this com interop toolkit, create a new control, and put my C# version of my usercontrol on this new control.
Then, you should have a com-exposable version of that control. At least, that's in short how i do it.

Frederik Gheysels
ah perhaps I should have been more specific, I need to display the control in a Wn32 c++ app.
Rich
Yes, that's what he meant. You'll need to provide an ActiveX control host in your C++ code. ATL's CAxWindow or MFC's COleControlContainer for example. Don't write one yourself.
Hans Passant
Thanks, no no I don't want to write one I want to take advantage of existing technologies. Do you have link to an example of this?
Rich
Ah sorry, re-reading it I understand, sorry.
Rich
works like a charm, thanks.
Rich