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 控件?
基础教程推荐
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
