Process class and main window handle property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In the Process class there is a CloseMainWindow, why is there not a
BringMainWindowToForeground or similar method?

What would be the best way to do this if we jsut have the process info and
MainWindowHandle without PInvoke?


Thanks
 
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.

1. Why is Process.MainWindowHandle = 0 when infact it has a form created?

2. How can we easily get this handle and bring the window to the foreground
(top Zorder app).

Thanks
 
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.

Ok, its zero because its the running process, but I want the already
active process so I can bring that to the foreground and exit this
instance.

I am trying to have a single instance of the application only on
attempting to start the 2nd.
 
Meh, theyre all zero.


Ok, its zero because its the running process, but I want the already
active process so I can bring that to the foreground and exit this
instance.

I am trying to have a single instance of the application only on
attempting to start the 2nd.
 
Ok, Activating the window doesnt seem to be reliable, the MainWindowHandle
property is sometimes a value and sometimes ZERO.

Probably some timeing issue when getting the list of processes

Is there a more reliable way to do this? Im calling the user32.dll version
of SetForegroundWindow(processList[0].MainWindowHandle); then
SetActiveWindow(processList[0].MainWindowHandle);
 
Back
Top