开发者

How to use C# usercontrol in VC++ 6.0?

开发者 https://www.devze.com 2023-01-16 11:03 出处:网络
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 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号