本文介绍了将IntPtr窗口句柄转换为IWin32Window ^的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将从表单/控件的Handle属性获取的句柄转换为IWin32Window ^?
How do I convert a handle acquired from a form/control's Handle property, to a IWin32Window^ ?
推荐答案
(这将获得你的Control对象,它实现了IWin32Window接口。)
(That gets you the Control object, which implements the IWin32Window interface.)
例如
IntPtr myWindowHandle = IntPtr(someVal);
IWin32Window^ w = Control::FromHandle(myWindowHandle);
请注意,这依赖于句柄是从窗体/控件的Handle属性获取。您不能对任意的Win32窗口句柄使用此技术。
Note that this relies on the handle being "acquired from a form/control's Handle property." You cannot use this technique with an arbitrary Win32 window handle.
这篇关于将IntPtr窗口句柄转换为IWin32Window ^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!