diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index d4d01e2cc..5a93d6ad9 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/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) diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 8d3088448..c110336e3 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/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, ¢er); + 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;