From fc10ee9909132173ed82fa305830e940dc1d14c7 Mon Sep 17 00:00:00 2001 From: Spitfire_x86 <33195187+spitfirex86@users.noreply.github.com> Date: Sat, 23 Sep 2023 00:06:20 +0200 Subject: [PATCH] restore tray icon after explorer restarts --- res/Resources.rc | Bin 10014 -> 10014 bytes src/main.c | 15 ++++++++++++++- topmostifier.vcxproj | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/res/Resources.rc b/res/Resources.rc index 0788861b7d99b3fccc0973df30bfd09a6835fc52..63b51fec88ca5523ef45821c83909b211622c334 100644 GIT binary patch delta 46 zcmbQ|H_vZFi!7tzg^ A{Qv*} diff --git a/src/main.c b/src/main.c index 48c1318..b201a9e 100644 --- a/src/main.c +++ b/src/main.c @@ -149,6 +149,8 @@ BOOL fn_bProcessCmds( HWND hWnd, WPARAM wParam, LPARAM lParam ) BOOL CALLBACK fn_bTopmostifierDlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { + static UINT s_uTaskbarMsg; + switch ( uMsg ) { case WM_INITDIALOG: @@ -157,7 +159,9 @@ BOOL CALLBACK fn_bTopmostifierDlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hIconSmall); fn_bCreateTrayIcon(hWnd); - + /* needed to handle re-creating tray icon if explorer restarts */ + s_uTaskbarMsg = RegisterWindowMessage("TaskbarCreated"); + g_hListWnd = GetDlgItem(hWnd, IDC_WNDLIST); g_hAlpha = GetDlgItem(hWnd, IDC_ALPHASLIDER); g_hTopmost = GetDlgItem(hWnd, IDC_TOPMOST); @@ -218,6 +222,15 @@ BOOL CALLBACK fn_bTopmostifierDlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR fn_vDeleteTrayIcon(hWnd); PostQuitMessage(0); return TRUE; + + default: + if ( uMsg == s_uTaskbarMsg ) + { + /* explorer died and/or was restarted, create the icon again */ + fn_bCreateTrayIcon(hWnd); + return TRUE; + } + break; } return FALSE; diff --git a/topmostifier.vcxproj b/topmostifier.vcxproj index 198dc72..61028ab 100644 --- a/topmostifier.vcxproj +++ b/topmostifier.vcxproj @@ -74,12 +74,15 @@ true src\;res\;%(AdditionalIncludeDirectories) MultiThreaded + true + false Windows true true true + false