benbuck / rbtray

A fork of RBTray from http://sourceforge.net/p/rbtray/code/.
GNU General Public License v2.0
1.08k stars 89 forks source link

Fix for #31 #32

Closed Andrzej-W closed 5 years ago

Andrzej-W commented 5 years ago

Normal sequence of events after Win+Alt+Down is:

  1. MinimizeWindowToTray
  2. AddWindowToTray
  3. AddToTray

and then ShowWindow(hwnd, SW_HIDE); in line https://github.com/benbuck/rbtray/blob/master/RBTray.cpp#L113 is called. Everything works correctly.

On my two computers after this sequence of steps

  1. Press Win+Alt+Down.
  2. Click icon in tray. Program is restored, icon disappears. VERY IMPORTANT: don't move your mouse after clicking.
  3. Press Win+Alt+Down.

I see the same steps 1-3 in program, but from inside of ShowWindow(hwnd, SW_HIDE); call RefreshWindowInTray is called. Then in line https://github.com/benbuck/rbtray/blob/master/RBTray.cpp#L167 function IsWindowVisible(hwnd) returns TRUE and then RemoveWindowFromTray(hwnd); is called.

To fix the problem we have to hide the program window before AddWindowToTray call.