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 控件?


基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01