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);
<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Meh, theyre all zero.
<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
<di********@discussion.microsoft.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl... 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.
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
<di********@discussion.microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
> 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
>
>