I want to avoid multiple executions of my application and set the focus on the already running instance when the application is started another time.
I have made the application a singleton by using a mutex, which works fine. But I encountered an issue when bringing it to front. The code for this is taken from these SO answers:
https://stackoverflow.com/a/7358286/2505186
https://stackoverflow.com/a/2315093/2505186
SetForegroundWindow(hWnd);
ShowWindow(hWnd, SW_RESTORE);
At the beginning it always failed to bring the window to front. After some while, I found that it is actually working, but not fully. The only thing that came to front was this little symbol:
This is the overlay icon of Teamviewer (I'm using version 8). Instead of my application, only this icon is brought to front:
When I log off at Teamviewer, the focussing on my application is working as expected. :-)
Why does it not work with Teamviewer logged on?
What functions do I need to execute to make it work also with Teamviewer?
I tested the "Bring to front" function of Sysinternals ProcessExplorer... it's working. So they must be using functions that are able to overcome this problem.