Ok, Activating the window doesnt seem to be reliable, the MainWindowHandl e
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 SetForegroundWi ndow(processLis t[0].MainWindowHand le); then
SetActiveWindow (processList[0].MainWindowHand le);
<di********@dis cussion.microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Meh, theyre all zero.
<di********@dis cussion.microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
<di********@dis cussion.microso ft.com> wrote in message
news:u8******** *****@TK2MSFTNG P10.phx.gbl... I tried calling the flat SetActiveWindow (HWND hWnd) funtion but the
Process.MainWin dowHandle = 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.
1. Why is Process.MainWin dowHandle = 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
<di********@dis cussion.microso ft.com> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
> Hi,
>
> In the Process class there is a CloseMainWindow , why is there not
a > BringMainWindow ToForeground or similar method?
>
> What would be the best way to do this if we jsut have the process info and
> MainWindowHandl e without PInvoke?
>
>
> Thanks
>
>