将IntPtr窗口句柄转换为IWin32Window ^ [英] Convert an IntPtr window handle to IWin32Window^

查看:1723
本文介绍了将IntPtr窗口句柄转换为IWin32Window ^的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将从表单/控件的Handle属性获取的句柄转换为IWin32Window ^?

How do I convert a handle acquired from a form/control's Handle property, to a IWin32Window^ ?

推荐答案

Control.FromHandle

(这将获得你的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 ^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆