Browse Source

Fix Notepad++ blocked when closed minimized or from systray

When Notepad++ is minimized and there are 2 or more unsaved opened files,
close Notepad++ directly from the taskbar (no periodic backup) will launch modal Save All dialog,
which will not be on the foreground. Hence the blocage of Notepad++.

This commit fixes the issue above.

Fix #14718, close #14725
pull/14789/head
xomx 9 months ago committed by Don Ho
parent
commit
f66dd91046
  1. 17
      PowerEditor/src/Notepad_plus.cpp
  2. 5
      PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp

17
PowerEditor/src/Notepad_plus.cpp

@ -2449,13 +2449,20 @@ int Notepad_plus::doSaveOrNot(const TCHAR* fn, bool isMulti)
if ((NppParameters::getInstance()).isEndSessionCritical())
return IDCANCEL; // simulate Esc-key or Cancel-button as there should not be any big delay / code-flow block
// In case Notepad++ is iconized into notification zone
if (!::IsWindowVisible(_pPublicInterface->getHSelf()))
// In case Notepad++ is minimized into taskbar or iconized into notification zone
if (::IsIconic(_pPublicInterface->getHSelf()))
{
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
::ShowWindow(_pPublicInterface->getHSelf(), SW_RESTORE);
}
else
{
if (!::IsWindowVisible(_pPublicInterface->getHSelf()))
{
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
// Send sizing info to make window fit (specially to show tool bar.)
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
// Send sizing info to make window fit (specially to show tool bar.)
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
}
}
if (!isMulti)

5
PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp

@ -79,10 +79,15 @@ void StaticDialog::goToCenter(UINT swpFlags)
{
RECT rc{};
::GetClientRect(_hParent, &rc);
if ((rc.left == rc.right) || (rc.top == rc.bottom))
swpFlags |= SWP_NOSIZE; // sizing has no sense here
POINT center{};
center.x = rc.left + (rc.right - rc.left)/2;
center.y = rc.top + (rc.bottom - rc.top)/2;
::ClientToScreen(_hParent, &center);
if ((center.x == -32000) && (center.y == -32000)) // https://devblogs.microsoft.com/oldnewthing/20041028-00/?p=37453
swpFlags |= SWP_NOMOVE; // moving has no sense here (owner wnd is minimized)
int x = center.x - (_rc.right - _rc.left)/2;
int y = center.y - (_rc.bottom - _rc.top)/2;

Loading…
Cancel
Save