如何将窗体显示为程序中不存在的窗口的子级?
我有一个应该是父对象的窗口句柄,但在表单上看不到任何用于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发布于 2011-02-16 22:33:32
哇,我刚刚找到了IWin32Window上的文档,发现它只是一个属性……Handle。是的,那么我当然可以很容易地让这个NativeWindowWrapper类...
我还没有测试它,但我相信它会工作得很好……
Public Class NativeWindowWrapper
Implements IWin32Window
Private _Handle As IntPtr
Public ReadOnly Property Handle As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _Handle
End Get
End Property
Public Sub New(ByVal Handle As IntPtr)
Me._Handle = Handle
End Sub
End Classhttps://stackoverflow.com/questions/4988756
复制相似问题