dziemborowicz / hourglass

The simple countdown timer for Windows.
MIT License
650 stars 114 forks source link

Bring window to the front when launching second instance of the app #133

Open dziemborowicz opened 7 years ago

dziemborowicz commented 7 years ago

When launching the first instance of Hourglass, the app is brought to the front.

When launching a second (or subsequent) instance of Hourglass, the app is not always brought to the front. Additionally, hovering over the taskbar entry for Hourglass shows a transparent window (see attached screenshots comparing hovering for the first instance vs. the second instance).

screenshot_hg1

screenshot_hg2

dziemborowicz commented 7 years ago

The likely cause is the single-instance behavior of Hourglass. When you launch Hourglass.exe a second (or subsequent) time, the new process sends a message to the already running instance of Hourglass.exe and instructs it to launch a new window. The new process then exits, and the old process now shows two windows.

The problem with this is that the old process may not currently be in the foreground, and, as a result, is not able to force its window to become the foreground window.