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