Can you start the process on top of the top window? (csharp wpf)

Can I start the process on top of the top window? (csharp wpf) I have the following, but the current window before it (the wpf window using the window class with topmost = true) remains at the top of the process when the process starts.

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_);
}
+2
source share
1 answer

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

However, this approach has disadvantages .

+3
source

Source: https://habr.com/ru/post/1650024/


All Articles