在 C++ 中编写控件的最佳方法是什么?以便它可以被 C++ 使用和 C# 程序?
我有一个用 C# 编写的自定义控件,我想将其移植到 C++,因为它太慢,而且我想在 C++ 程序和 C# 程序中使用它。
我研究过 MFC Active X、ATL Active X 和 .NET C++。它们看起来都过于复杂。我真的很想避免使用 .NET C++,因为在 C++ 程序中涉及 .NET 似乎毫无意义。
此外,似乎没有任何关于编写 10 年前的 Active X 控件的优秀教程。
你们知道有哪些针对 Visual Studio 2008 的不错的 ActiveX 教程吗?
有没有其他方法可以让我无需编写 COM 组件即可实现我的目标。我可以用 C++ 编写一个普通控件并将其粘贴到 DLL 中并使其可供 C++ 和 C# 程序使用吗?我不关心与 GUI 表单设计器的兼容性。
谢谢!
I have a custom control written in C# that I would like to port to C++ because it is too slow, and also because I would like to use it in a C++ program as well as C# programs.
I've looked at MFC Active X, ATL Active X, and .NET C++. They all seem needlessly complicated. I'd really like to avoid .NET C++ because involving .NET in a C++ program just seems pointless.
Also there don't seem to be any good tutorials on writing active X controls that aren't a decade old.
Do you guys know of any decent ActiveX tutorials that target Visual Studio 2008?
Is there any other way that I can accomplish my goals without having to write a COM component. Can I just write a normal control in C++ and stick it in a DLL and have it be usable by both C++ and C# programs? I don't care about compatibility with GUI form designers.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我原来的答案如下。我将把它留给有类似情况的人。
根据您的评论,我仍然担心您不了解 .NET C++(最近被 C++/CLI 取代)所扮演的角色。我认为这可能是您的完美解决方案。例如,它允许您用 C++ 编写一个 ActiveX 控件(这是我目前推荐的),然后立即为其编写一个 .NET 包装器,而无需离开 C++,而是使用相当大的 C++ 扩展。
还有一个补充:如果可能的话,使用 Visual Studio 2010。 C++/CLI 比其前辈有了巨大的进步。至于 ActiveX,如果指南是旧的,请不要担心。过去十年没有太大变化。
My original answer was as follows. I will leave it here for people in similar situations.
Based on your comment, I am still concerned that you don't understand the role that .NET C++ (recently replaced by C++/CLI) plays. I think that might just be the perfect solution for you. It allows you to, say, write an ActiveX control in C++ (which is what I would recommend at this point), and then immediately write a .NET wrapper for it without leaving C++, but instead using a rather large C++ extension.
Yet another addition: Use Visual Studio 2010 if at all possible. C++/CLI is a huge improvement over its predecessors. As for ActiveX, don't worry if the guides are old. It hasn't changed much in the past decade.