c# - 使用 windowHandle 显示 WPFHidden 窗口
问题描述
我创建了一个 WPF 窗口并向其添加了一些控件。现在我将获取窗口句柄并隐藏窗口。
我将创建单独的应用程序(控制台)并使用windowHandle
下面的 api 来显示窗口
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
但问题是窗口带有黑色背景。不显示控件。
任何人都可以帮助如何完成它。(使用窗口句柄显示 WPF 窗口)
WPF 窗口代码
var windowInteropHelper = new WindowInteropHelper(this);
int tempHandle = (int)windowInteropHelper.Handle;
string filePath = @"C:\windowHandleLog.txt";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.AppendAllText(filePath, tempHandle.ToString());
this.Hide();
控制台应用程序代码:
string filePath = @"C:\windowHandleLog.txt";
string handle = File.ReadAllText(filePath);
int windowHandle = Convert.ToInt32(handle);
ShowWindow(windowHandle, SW_SHOW);
解决方案
推荐阅读
- reactjs - 如何将 http-proxy-middleware 与 react 和 passport.js 一起使用
- docker - 生产环境中的 presto docker 容器
- eclipse - 找不到 mdb ejb3
- excel - 删除输入月份之外的日期
- firebase - 如何从 Firebase 存储地图中删除特定项目?
- javascript - 是否可以在不使用 JSON 服务器的情况下使用 Javascript 访问 JSON 文件?
- r - 如何离散化只有 2 个不同值的变量?
- excel - long 支持小数吗?
- r - 检查字符串是否包含向量 [R] 中的项目以外的任何内容
- java - 如何从 onitemclick 获取数据并将其显示在另一个活动(Android Dev)上?