如何将Win32窗口设置为WPF窗口的所有者?
我想在旧版 win32 应用程序中使用 WPF 窗口。 我想以类似的方式表现它们,就像 WPF 窗口始终显示在 win32 窗口顶部。
为此,我想将 WPF 窗口的所有者设置为 win32 窗口,但我不知道如何实现这一点。
这里有什么帮助吗?
由于答案隐藏在某个链接后面,因此这里的代码实现了这一点:
System::Windows::Interop::WindowInteropHelper^ helper = gcnew System::Windows::Interop::WindowInteropHelper(myWpfChildWindow);
helper->Owner = (System::IntPtr)myMainWindowHWND;
I want to use WPF windows in a legacy win32 application.
I'd like to behave them in a similar way, like the WPF window always being displayed on top of the win32 window.
For this I'd like to set the owner of the WPF window to the win32 windows, but I got no idea how to achieve this.
Any help here?
Since the answer is hidden behind some link, here the code that did the trick:
System::Windows::Interop::WindowInteropHelper^ helper = gcnew System::Windows::Interop::WindowInteropHelper(myWpfChildWindow);
helper->Owner = (System::IntPtr)myMainWindowHWND;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本文介绍如何获取两者的句柄以及如何使 WPF 窗口成为 win32 窗口的透明覆盖层。
http://dedjo.blogspot.com/2007/ 04/transparent-wpf-control-over-unmanagement.html
本文使用 WindowInteropHelper 来完成类似的功能。
http://blogs.msdn.com/wpfsdk/archive/2007/04/03/centering-wpf-windows-with-wpf-and-non-wpf-owner-windows.aspx
MSDN WindowInteropHelper 页面:
http://msdn.microsoft。 com/en-us/library/system.windows.interop.windowinterophelper.aspx
希望有所帮助,
埃德
This article shows how to get the handles for both as well as how to make the WPF window become a transparent overlay for the win32 window.
http://dedjo.blogspot.com/2007/04/transparent-wpf-control-over-unmanaged.html
This article uses a WindowInteropHelper to accomplish similar functionality.
http://blogs.msdn.com/wpfsdk/archive/2007/04/03/centering-wpf-windows-with-wpf-and-non-wpf-owner-windows.aspx
MSDN page on WindowInteropHelper:
http://msdn.microsoft.com/en-us/library/system.windows.interop.windowinterophelper.aspx
Hope that helps,
Ed
SetParent()
怎么样? ?我知道将 WPF 窗口作为 Windows 窗体的 MDI 子窗口时有效。How about
SetParent()
? I know works when making a WPF window an MDI Child of a Windows Form.