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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.