diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index ec80b6853..57c869be6 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2480,6 +2480,33 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_RESTOREMONOINSTANCE: + { + // When mono instance, bring this one to front + if (_pTrayIco != nullptr && _pTrayIco->isInTray()) + { + // We are in tray, restore properly.. + ::SendMessage(hwnd, NPPM_INTERNAL_MINIMIZED_TRAY, 0, WM_LBUTTONUP); + } + else + { + // We were not in tray.. + int sw = 0; + + if (::IsZoomed(hwnd)) + sw = SW_MAXIMIZE; + else if (::IsIconic(hwnd)) + sw = SW_RESTORE; + + if (sw != 0) + ::ShowWindow(hwnd, sw); + + ::SetForegroundWindow(hwnd); + } + + return TRUE; + } + case WM_SYSCOMMAND: { const NppGUI & nppgui = (nppParam.getNppGUI()); diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 2b02bca04..db94d6829 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -644,6 +644,7 @@ #define NPPM_INTERNAL_CLEANSMARTHILITING (NOTEPADPLUS_USER_INTERNAL + 68) #define NPPM_INTERNAL_CLEANBRACEMATCH (NOTEPADPLUS_USER_INTERNAL + 69) #define NPPM_INTERNAL_WINDOWSSESSIONEXIT (NOTEPADPLUS_USER_INTERNAL + 70) + #define NPPM_INTERNAL_RESTOREMONOINSTANCE (NOTEPADPLUS_USER_INTERNAL + 71) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index cfe6a7df9..71fbabe8f 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -531,17 +531,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) // First of all, destroy static object NppParameters nppParameters.destroyInstance(); - int sw = 0; - - if (::IsZoomed(hNotepad_plus)) - sw = SW_MAXIMIZE; - else if (::IsIconic(hNotepad_plus)) - sw = SW_RESTORE; - - if (sw != 0) - ::ShowWindow(hNotepad_plus, sw); - - ::SetForegroundWindow(hNotepad_plus); + // Restore the window, bring it to front, etc + ::SendMessage(hNotepad_plus, NPPM_INTERNAL_RESTOREMONOINSTANCE, 0, 0); if (params.size() > 0) //if there are files to open, use the WM_COPYDATA system {