How do I display an MFC control in a windows forms application?(如何在 Windows 窗体应用程序中显示 MFC 控件?)
问题描述
我想创建一个 Windows 窗体控件,该控件显示一个 MFC 控件,例如 CIPAddressCtrl
,具有工作的 Text 属性和 TextChanged 事件.如何在 Windows 窗体应用程序中显示 MFC 控件?如有必要,我很乐意使用 C++/CLI.
I'd like to create a windows forms control which shows an MFC control such as CIPAddressCtrl
, with a working Text property and TextChanged event. How do I display an MFC control in a windows forms application? I'm happy to use C++/CLI if necessary.
注意:我不是在问如何创建一个全新的窗体控件.我想在 Windows 窗体应用中托管旧版控件.
NOTE: I'm not asking how to create a brand new windows forms control; I want to host a legacy control in a windows forms app.
推荐答案
这篇文章 提供了一个包装你的 MFC 控件的解决方案.巧妙的技巧是在 Control::OnHandleCreated 的覆盖中使用 SubclassWindow.其余代码涉及使用 .NET 属性手动包装 MFC 控件的属性.
This article presents a solution which will wrap your MFC control. The neat trick of this is its use of SubclassWindow in the override of Control::OnHandleCreated. The rest of the code involves manually wrapping the attributes of the MFC control with .NET properties.
这篇关于如何在 Windows 窗体应用程序中显示 MFC 控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Windows 窗体应用程序中显示 MFC 控件?


- 带问号的 nvarchar 列结果 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 使用 rss + c# 2022-01-01