I am using
System.Diagnostics.Process.Start(ProcessInfo);
to open a TEXT file in notepad from within my windows form application.
Detai
Other that specifying the initial window state (normal, hidden, etc), you have basically no control over how the newly launched application starts up and where it shows itself.
The best bet here is to launch the application, then use its window handle to tell it to move. This all requires using P/Invoke, to call MoveWindow. The C# signatures for all of those functions are on pinvoke.net.
Here's a very simple (VB.NET) example that shows the basic idea. In this case, as @Lloyd points out, the window handle you need is the Process.MainWindowHandle
you get back from Process.Start
. Note that Process.MainWindowHandle
isn't filled in immediately; you typically need to call WaitForInputIdle
to make sure the window actually gets created. If MainWindowHandle
is 0 then you'll know it's too soon.