简体   繁体   English

如何在Win32应用程序中托管ac#控件?

[英]How can I host a c# control in a win32 app?

I've developed ac# control, and I can reuse this in other c# apps and that works really well. 我已经开发了ac#控件,并且可以在其他c#应用程序中重用此控件,并且效果很好。

However I want to host this control in a Win32 c++ app, is there a way to do this? 但是我想在Win32 c ++应用程序中托管此控件,有没有办法做到这一点?

I was wondering if it would work with managed c++, however I can't quite figure out if this is possible. 我想知道它是否可以与托管c ++一起工作,但是我不太清楚这是否可行。

Any help would be gratefully received. 任何帮助将不胜感激。

Cheers Rich 致富

You can use the Com Interop Toolkit to solve this. 您可以使用Com Interop Toolkit解决此问题。

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. 我就是这样做的:我在C#中创建控件,当我想将该控件公开给另一个Win32应用程序时,我通过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. 我使用此com interop工具包创建一个新项目,创建一个新控件,并将我的usercontrol的C#版本放在此新控件上。
Then, you should have a com-exposable version of that control. 然后,您应该具有该控件的可公开版本。 At least, that's in short how i do it. 至少,这就是我的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM