Can you launch a process on top of the topmost window? (csharp wpf)

一个人想着一个人 提交于 2019-11-28 10:07:08

问题


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_);
}

回答1:


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

However, this approach has drawbacks.



来源:https://stackoverflow.com/questions/8312535/can-you-launch-a-process-on-top-of-the-topmost-window-csharp-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!