如何将Win32窗口设置为WPF窗口的所有者? [英] How to set Win32 window as owner of WPF window?

查看:254
本文介绍了如何将Win32窗口设置为WPF窗口的所有者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在旧版Win32应用程序中使用WPF窗口. 我想以类似的方式表现它们,例如WPF窗口始终显示在win32窗口的顶部.

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.

为此,我想将WPF窗口的所有者设置为win32窗口,但是我不知道如何实现.

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.

这里有帮助吗?

由于答案隐藏在某个链接的后面,因此,完成此操作的代码如下:

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;

推荐答案

本文介绍了如何获取两者的句柄以及如何使WPF窗口成为win32窗口的透明覆盖.

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://blogs.microsoft.co.il/blogs/tamir/archive/2007/04/11/Transparent-WPF-control-over-unmanaged-window-handle.aspx

本文使用WindowInteropHelper完成类似的功能.

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

WindowInteropHelper上的MSDN页面:

MSDN page on WindowInteropHelper:

http://msdn.microsoft.com/zh-cn/library/system.windows.interop.windowinterophelper.aspx

希望有帮助, 埃德

这篇关于如何将Win32窗口设置为WPF窗口的所有者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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