2

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_);
}
Chris
  • 968
  • 16
  • 27
  • 5
    [What if two programs did this](http://blogs.msdn.com/b/oldnewthing/archive/2005/06/07/426294.aspx)? – SLaks Nov 29 '11 at 14:37
  • In wpf I beleive that all topmost windows are above all non-topmost and the 'active' topmost is above all other topmost, if that helps sLak. for my question though, i want to know how to get a process that is launched to be marked as topmost as well. – Chris Nov 29 '11 at 14:45

1 Answers1

3

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

However, this approach has drawbacks.

Community
  • 1
  • 1
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • This is a good idea, but in my case it will not work because the child window opens up inside the constrained boundaries of the parent so it is too small. – Chris Nov 29 '11 at 15:10
  • Marking this answer as it was the most useful. I instead used a workaround (made the other windows at the same level instead of any of them being topmost, and then set the window which needed to be viewed as active). – Chris Dec 12 '11 at 21:25