gpt4 book ai didi

c# - 使用 hWnd 设置 Window.Owner

转载 作者:可可西里 更新时间:2023-11-01 08:54:47 26 4
gpt4 key购买 nike

在我的 WPF/C# 应用程序中,我使用如下代码创建了一个对话窗口:

Window dialog = new MyDialog() as Window;
dialog.Owner = Window.GetWindow(this);
dialog.ShowDialog();

如何将对话框所有者设置为另一个应用程序窗口的 hWnd?

我需要的功能只是在对话框可见时阻止“所有者窗口”。

最佳答案

使用WindowInteropHelper :

Window dialog = new MyDialog();
WindowInteropHelper wih = new WindowInteropHelper(dialog);
wih.Owner = ownerHwnd;
dialog.ShowDialog();

关于c# - 使用 hWnd 设置 Window.Owner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13842869/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com