F
Frank Stegerwald
Hi,
I have a windows forms application that is single instance.
It checks its existance with a mutex and shows itself with the following
lines of code if it is already running (using P/Invoke):
AttachThreadInput(_hThread, hThread, 1);
BringWindowToTop(hWnd);
ShowWindow(hWnd, SW_RESTORE);
SetForegroundWindow(hWnd);
AttachThreadInput(_hThread, hThread, 0);
On XP Systems the ForegroundLockTimeout is set to 0 to achieve this
behaviour.
Sometimes, when I launch the App from e.g. Windows explorer,
the application does not get the focus correctly. It is shown in
the taskbar as active, but the calling application (here windows
explorer) still has the focus somehow. I need to explicitely klick
into the app to activate it.
This behaviour is not always. very strange. We also tried this with
a Win32 Application and we can reproduce the behaviour there as well.
So it has nothing to do with .NET
Any solutions to this problem?
Thanks in advance for ANY help
Greetings
Frank Stegerwald
I have a windows forms application that is single instance.
It checks its existance with a mutex and shows itself with the following
lines of code if it is already running (using P/Invoke):
AttachThreadInput(_hThread, hThread, 1);
BringWindowToTop(hWnd);
ShowWindow(hWnd, SW_RESTORE);
SetForegroundWindow(hWnd);
AttachThreadInput(_hThread, hThread, 0);
On XP Systems the ForegroundLockTimeout is set to 0 to achieve this
behaviour.
Sometimes, when I launch the App from e.g. Windows explorer,
the application does not get the focus correctly. It is shown in
the taskbar as active, but the calling application (here windows
explorer) still has the focus somehow. I need to explicitely klick
into the app to activate it.
This behaviour is not always. very strange. We also tried this with
a Win32 Application and we can reproduce the behaviour there as well.
So it has nothing to do with .NET
Any solutions to this problem?
Thanks in advance for ANY help
Greetings
Frank Stegerwald