问题描述
我想创建一个 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 控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)