Skip to content

Commit

Permalink
restore tray icon after explorer restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfirex86 committed Sep 22, 2023
1 parent 556438c commit fc10ee9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Binary file modified res/Resources.rc
Binary file not shown.
15 changes: 14 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions topmostifier.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>src\;res\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit fc10ee9

Please sign in to comment.