Minimise a 3rd-party app

excession

New member
Joined
Oct 5, 2005
Messages
4
Programming Experience
1-3
Hi,

I have a Windows Form application that launches a 3-party application, does some fancy stuff via its API and reports back a pile of data about what it's found. What I'd like to know is, how do I minimise the 3rd-party app (taskbar is fine) and keep my Windows Form application in the foreground? Any help much appreciated!

Thanks - e.
 
If you don't need to ever see the other app at all, then you can start it in a minimized state by doing this:

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] psi [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ProcessStartInfo = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ProcessStartInfo("app.exe")
psi.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(psi)
[/SIZE]

If you need to start it normally and minimize it later, you will need to use the SetWindowPlacement API function.
 
Hmmm, I was looking at the Process way of doing it, but my application is launched as a new Application object so I can access it's API and take control of it. Is there a way to 'grab' a running process, say via GetProcesses() and force it to minimise from that point?
 
All you need use the SetWindowPlacement API function to minimise a window is it's handle. Once you have a Process object, whether it is one you Started yourself or an existing one you got via GetProcesses, GetProcessById or GetProcessesByName, you can pass its MainWindowHandle property to SetWindowPlacement.
 
Back
Top