您可以启动的最顶层窗口的顶部有一个过程? (CSHARP WPF) [英] Can you launch a process on top of the topmost window? (csharp wpf)

查看:319
本文介绍了您可以启动的最顶层窗口的顶部有一个过程? (CSHARP WPF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能发动的最顶层窗口的顶部的过程? (CSHARP WPF)
 我有以下,但这个之前,在当前窗口(即具有最顶层= true的使用WPF窗口窗口类),仍然在进程展开的进程之上。

 如果(System.IO.File.Exists(MY_CALC_PATH))
{
    的System.Diagnostics.Process helpProcess =新的System.Diagnostics.Process();
    helpProcess.StartInfo.FileName =的calc.exe;
    helpProcess.Start();
    helpProcess.WaitForInputIdle();
    BringWindowToTop(helpProcess.MainWindowHandle);
    SetWindowPos(helpProcess.MainWindowHandle,myCurrentTopmostWinHnd,0,0,0,0,SWP_NOSIZE_);
}


解决方案

您需要通过调用的 的setparent

然而,该方法<一href=\"http://stackoverflow.com/questions/3459874/good-or-evil-setparent-win32-api-between-different-processes\">has缺点的。

Can you launch a process on top of the topmost window? (csharp wpf) I have the following, but the current window before this one ( a wpf window using window class that has topmost=true ), remains on top of the process when the process is launched..

if (System.IO.File.Exists(MY_CALC_PATH))
{
    System.Diagnostics.Process helpProcess = new System.Diagnostics.Process();
    helpProcess.StartInfo.FileName = "calc.exe";
    helpProcess.Start();
    helpProcess.WaitForInputIdle();
    BringWindowToTop(helpProcess.MainWindowHandle);
    SetWindowPos(helpProcess.MainWindowHandle, myCurrentTopmostWinHnd, 0, 0, 0, 0, SWP_NOSIZE_);
}

解决方案

You need to set the Calculator window as a child window of your TopMost window by calling SetParent.

However, this approach has drawbacks.

这篇关于您可以启动的最顶层窗口的顶部有一个过程? (CSHARP WPF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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