c# - 使用 hWnd 设置 Window.Owner

标签 c# wpf winapi

在我的 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/

相关文章:

c# - 按钮未以编程方式触发 ASP.NET 控件上的事件

wpf - 将进度条添加到 WPF 控件的背景

c# - 为什么我可以在 Snoop 中看到 PasswordBox 的密码?

winapi - 在 Windows XP 和 Vista 上设置线程 UI 语言?

c++ - 在 c/c++ 中更改 Windows 服务的状态

c# - 在 MVC 项目中使用 System.Device

C# 窗体 : Accessing public properties from other forms & difference between static and public properties

.net - 如何用给定枚举中的所有项目填充XAML中的WPF组合框?

windows - 如何检查目录符号链接(symbolic link)的目标是否存在?

c# - ElasticSearch C# 客户端 (NEST) : access nested aggregation with Spaces