I created an application in C # to address some needs of an existing application in the enterprise. Recently we had to buy another application to support billing. These applications running is as follows:
1st Application-> 2 Application -> 3 Application
When I do "Process.Start" for the third application "it opens but after a few seconds it loses focus for the 1st Application. Anybody know how can I avoid this?
You need to know the window class and/or title and then can use FindWindow to get a window handle for the window:
Using the window handle you can change the window back to normal display using SetWindowPos:
In example, if the window has a class name of "App 3"
To find the window's class and title, start the CE remote tool "CE Spy" (part of VS installation) when app 3 is started. Then browse thru the window list and look the app 3 window. Double click the entry in the list and you will get the class name and title of app 3.
Instead of the extra SetWindowPos you can also use the simple ShowWindow API:
For details about pinvoke of FindWindow and SetWindowPos see pinvoke.net and MSDN. Best book about Win32 programming is Charles Petzold's Programming Windows.
When you started the process you need the OS give some time to settle the app (let's say 1-3 seconds), before you change the window.