Fixed dock-able panels not restoring for mono instances

The bug happens when Notepad++ is in the tray, and is restored via mono instance restore mechanism.

Fixes #9454, close #12817
pull/13027/head
Rubat 2023-01-19 04:45:47 +02:00 committed by Don Ho
parent 05977f6308
commit afacc8338e
3 changed files with 30 additions and 11 deletions

View File

@ -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());

View File

@ -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)

View File

@ -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
{