表单上 SetParent() 的托管方法
如何将窗体显示为不在我的程序中的窗口的子窗口?
我有一个应该是父级的窗口句柄,但我在表单上没有看到任何 SetParent() 的托管方法。有吗?似乎 form.Show()
方法只接受实现 IWin32Window 的托管对象。
如果没有托管方法,那么声明 API 以最大程度地兼容未来系统的首选方法是什么?像这样?:
<DllImport("user32.dll")> _
Private Shared Function SetParent(hWndChild As IntPtr, hWndNewParent As IntPtr) As IntPtr
End Function
是否可以构建一个实现 IWin32Window 并以某种方式包装窗口的类?这样做会很方便,但我不熟悉 IWin32Window:
frmMyForm.Show(New NativeWindowWrapper(12345)) 'Where 12345 is the hWnd of the window I want to wrap
How can I show a form as a child of a window that isn't in my program?
I have a window handle to what should be the parent, but I don't see any managed method for SetParent() on a form. Is there one? It also seems that the form.Show()
method only accepts managed objects implementing IWin32Window.
If there isn't a managed method, what is the preferred method for declaring the API for maximum compatibility with future systems? Like this?:
<DllImport("user32.dll")> _
Private Shared Function SetParent(hWndChild As IntPtr, hWndNewParent As IntPtr) As IntPtr
End Function
Is it possible to build a class that implements IWin32Window and somehow wraps up a window? It would be handy do something like this, but I am not familiar with IWin32Window:
frmMyForm.Show(New NativeWindowWrapper(12345)) 'Where 12345 is the hWnd of the window I want to wrap
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哇哦,我刚刚找到了 IWin32Window 的文档,发现它只有一个属性...
Handle
。是的,那么我当然可以轻松地制作这个 NativeWindowWrapper 类...我还没有测试它,但我确信它会工作得很好...
Oh wow, I just found the documentation on IWin32Window, and see that it is only one property...
Handle
. Yes, then of course I can easily make this NativeWindowWrapper class...I haven't tested it yet, but I am sure it will work just fine...