tags:

views:

16

answers:

1

Hi,

I have a legacy application written using VC++ MFC. For a latest feature, I have created a C# user control. I want to be able to use this control in the legacy VC application. How can I do it?

+1  A: 

What do you mean by legacy application? Can you compile MFC application in Visual Studio 2005? Can you add Common Language Runtime (clr) support during compilation? If so, it's pretty simple to host a user control in MFC application. Just follow the instructions here.

If you can't do that, just create a wrapper C++/CLI AcitveX control and host the user control in it. Resize the hosted control to fill the area of the ActiveX. Now you can use this ActiveX in your MFC application. The drawback is like Wrapper pattern, you have to forward all public methods and properties from UserControl to ActiveX Control.

Liton
Thanks for your repsonse Liton. As I can not compile my app in VS2005, I will try second option. I will let you know about the result.