Vb.net Question

Set focus on the application being opened?

I am opening a application from a winform. I want to focus on that application after opening. Currently when i open it, it opens behind the winform. Anyone know how to get me started? Here's how i'm opening my application from the form:

'set focus to that particular application or bring it in front of the winform application.

Answer Source

Try adding this declaration somewhere within your class:

 Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As IntPtr

...and starting the process this way:

Dim p As New System.Diagnostics.Process
p.StartInfo.FileName = "C:\myapplication.exe"
p.StartInfo.CreateNoWindow = False
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download