From 5aab1ddbf14012272bf3b8c2957b6b552eeef384 Mon Sep 17 00:00:00 2001 From: Udo Hoffmann Date: Sat, 3 Oct 2020 13:49:16 +0200 Subject: [PATCH] Make tray icon work again in administrator mode Fix #8528, close #8944 --- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/Notepad_plus_Window.cpp | 2 +- PowerEditor/src/NppBigSwitch.cpp | 6 +++--- PowerEditor/src/resource.h | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index fe7c3475f..988a0506c 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -389,7 +389,7 @@ LRESULT Notepad_plus::init(HWND hwnd) if (nppGUI._isMinimizedToTray && _pTrayIco == NULL) { HICON icon = ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)); - _pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, IDC_MINIMIZED_TRAY, icon, TEXT("")); + _pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, icon, TEXT("")); } checkSyncState(); diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index 51b693004..14137d5cb 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -185,7 +185,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin } else { - _notepad_plus_plus_core._pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); + _notepad_plus_plus_core._pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); _notepad_plus_plus_core._pTrayIco->doTrayIcon(ADD); } std::vector fileNames; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index b7cab3084..209f48530 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1909,10 +1909,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case WM_SYSCOMMAND: { const NppGUI & nppgui = (nppParam.getNppGUI()); - if (((nppgui._isMinimizedToTray && !_isAdministrator) || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) + if ((nppgui._isMinimizedToTray || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) { if (nullptr == _pTrayIco) - _pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); + _pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); _pTrayIco->doTrayIcon(ADD); ::ShowWindow(hwnd, SW_HIDE); @@ -1937,7 +1937,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } - case IDC_MINIMIZED_TRAY: + case NPPM_INTERNAL_MINIMIZED_TRAY: { switch (lParam) { diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 4ab2e0e4b..d94692a41 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -280,8 +280,6 @@ #define IDD_FILEVIEW_DIALOG 1000 -#define IDC_MINIMIZED_TRAY 67001 - #define IDD_CREATE_DIRECTORY 1100 #define IDC_STATIC_CURRENT_FOLDER 1101 #define IDC_EDIT_NEW_FOLDER 1102 @@ -448,6 +446,7 @@ #define NPPM_INTERNAL_EDGEMULTISETSIZE (NOTEPADPLUS_USER_INTERNAL + 51) #define NPPM_INTERNAL_UPDATECLICKABLELINKS (NOTEPADPLUS_USER_INTERNAL + 52) #define NPPM_INTERNAL_SCINTILLAFINDERWRAP (NOTEPADPLUS_USER_INTERNAL + 53) + #define NPPM_INTERNAL_MINIMIZED_TRAY (NOTEPADPLUS_USER_INTERNAL + 54) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000)