Use the right size of icon in system tray

Fix #8971, close #13419
This commit is contained in:
ozone10 2023-03-25 18:16:44 +01:00 committed by Don Ho
parent 2bcc32cb99
commit 7b4e700d49
4 changed files with 26 additions and 6 deletions

View File

@ -435,9 +435,10 @@ LRESULT Notepad_plus::init(HWND hwnd)
_dockingManager.init(_pPublicInterface->getHinst(), hwnd, &_pMainWindow);
if (nppGUI._isMinimizedToTray && _pTrayIco == NULL)
if (nppGUI._isMinimizedToTray && _pTrayIco == nullptr)
{
HICON icon = ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON));
HICON icon = nullptr;
Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon);
_pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, icon, TEXT(""));
}

View File

@ -188,7 +188,9 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
}
else
{
_notepad_plus_plus_core._pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT(""));
HICON icon = nullptr;
loadTrayIcon(_hInst, &icon);
_notepad_plus_plus_core._pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, icon, TEXT(""));
_notepad_plus_plus_core._pTrayIco->doTrayIcon(ADD);
}

View File

@ -100,6 +100,19 @@ public:
void setStartupBgColor(COLORREF BgColor);
static void loadIcon(HINSTANCE hinst, wchar_t* pszName, int cx, int cy, HICON* icon)
{
if (::LoadIconWithScaleDown(hinst, pszName, cx, cy, icon) != S_OK)
{
*icon = static_cast<HICON>(::LoadImage(hinst, pszName, IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR));
}
}
static void loadTrayIcon(HINSTANCE hinst, HICON* icon)
{
loadIcon(hinst, MAKEINTRESOURCE(IDI_M30ICON), ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), icon);
}
private:
Notepad_plus _notepad_plus_plus_core;
static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);

View File

@ -1357,8 +1357,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_GETNPPVERSION:
{
const TCHAR* verStr = VERSION_VALUE;
TCHAR mainVerStr[16];
TCHAR auxVerStr[16];
TCHAR mainVerStr[16]{};
TCHAR auxVerStr[16]{};
bool isDot = false;
int j = 0;
int k = 0;
@ -2537,7 +2537,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
if ((nppgui._isMinimizedToTray || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE))
{
if (nullptr == _pTrayIco)
_pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)), TEXT(""));
{
HICON icon = nullptr;
Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon);
_pTrayIco = new trayIconControler(hwnd, IDI_M30ICON, NPPM_INTERNAL_MINIMIZED_TRAY, icon, TEXT(""));
}
_pTrayIco->doTrayIcon(ADD);
_dockingManager.showFloatingContainers(false);