Skip to content

Commit

Permalink
+fix: missing toolbar if started minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiKoHoff committed Mar 2, 2024
1 parent 8bcc760 commit 54a7cfc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
7 changes: 6 additions & 1 deletion src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,12 @@ void MinimizeWndToTray(HWND hWnd) {
// Add the tray icon. If we add it before the call to DrawAnimatedRects,
// the taskbar gets erased, but doesn't get redrawn until DAR finishes.
// This looks untidy, so call the functions in this order
ShowNotifyIcon(hWnd, true);
SetNotifyIconTitle(hWnd);

// Hide the window
ShowWindow(hWnd, SW_HIDE);

Globals.bMinimizedToTray = true;
}

Expand Down Expand Up @@ -737,11 +740,13 @@ void RestoreWndFromTray(HWND hWnd) {

SetActiveWindow(hWnd);
SetForegroundWindow(hWnd);
Globals.bMinimizedToTray = false;

// Remove the tray icon. As described above, remove the icon after the
// call to DrawAnimatedRects, or the taskbar will not refresh itself
// properly until DAR finished
ShowNotifyIcon(hWnd, false);

Globals.bMinimizedToTray = false;
}

void RestoreWndFromTaskbar(HWND hWnd)
Expand Down
28 changes: 14 additions & 14 deletions src/Notepad3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,8 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow)
InitWindowCommon(hwndMain, true);
SetDialogIconNP3(hwndMain);

//assert("Attach Debugger" && 0);

// correct infos based on hwnd
g_DefWinInfo = _GetDefaultWinInfoByStrg(hwndMain, Settings2.DefaultWindowPosition);
s_WinCurrentWidth = g_IniWinInfo.cx;
Expand All @@ -1908,6 +1910,8 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow)
SetWindowTransparentMode(hwndMain, true, Settings2.OpacityLevel);
}

CreateBars(hwndMain, hInstance);

SetMenu(hwndMain, (Settings.ShowMenubar ? Globals.hMainMenu : NULL));
DrawMenuBar(hwndMain);

Expand Down Expand Up @@ -1941,24 +1945,22 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow)
//~SnapToWinInfoPos(hwndMain, g_IniWinInfo, SCR_NORMAL, SW_HIDE); ~ instead set all needed properties here:
SetWindowPos(hwndMain, Settings.AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

if (!s_flagStartAsTrayIcon) {
UpdateWindow(hwndMain);
if (!Settings.ShowTitlebar) {
SetWindowLong(hwndMain, GWL_STYLE, GetWindowLong(hwndMain, GWL_STYLE) & ~WS_CAPTION);
}
UpdateWindow(hwndMain);
if (!Settings.ShowTitlebar) {
SetWindowLong(hwndMain, GWL_STYLE, GetWindowLong(hwndMain, GWL_STYLE) & ~WS_CAPTION);
}
else {

if (s_flagStartAsTrayIcon || (nCmdShow & SW_MINIMIZE)) {
if (Settings.MinimizeToTray) {
MinimizeWndToTray(hwndMain);
}
else {
MinimizeWndToTaskbar(hwndMain);
nCmdShow = SW_MINIMIZE;
}
ShowNotifyIcon(hwndMain, true);
SetNotifyIconTitle(hwndMain);
}
ShowWindow(hwndMain, nCmdShow);
else {
ShowWindow(hwndMain, nCmdShow);
}

bool bOpened = false;

Expand Down Expand Up @@ -3417,7 +3419,7 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
// call SaveAllSettings() when Globals.hwndToolbar is still valid
SaveAllSettings(false);

// Remove tray icon if necessary
// Remove tray icon in any case
ShowNotifyIcon(hwnd, false);

//if (IS_VALID_HANDLE(s_hEvent)) {
Expand Down Expand Up @@ -4100,7 +4102,7 @@ LRESULT MsgTrayMessage(HWND hwnd, WPARAM wParam, LPARAM lParam)
RestoreWndFromTray(hwnd);
ShowOwnedPopups(hwnd, true);
} else if (iCmd == IDM_TRAY_EXIT) {
//ShowNotifyIcon(hwnd,false);
ShowNotifyIcon(hwnd,false);
CloseApplication();
}
}
Expand Down Expand Up @@ -7628,8 +7630,6 @@ LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
ShowOwnedPopups(hwnd, false);
if (Settings.MinimizeToTray) {
MinimizeWndToTray(hwnd);
ShowNotifyIcon(hwnd, true);
SetNotifyIconTitle(hwnd);
}
else {
MinimizeWndToTaskbar(hwnd);
Expand Down

0 comments on commit 54a7cfc

Please sign in to comment.