diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index be32f0055..9b9af30a1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -712,28 +712,34 @@ bool Notepad_plus::saveGUIParams() nppGUI._userDefineDlgStatus = (b?UDD_DOCKED:0) | (udd->isVisible()?UDD_SHOW:0); // Save the position -/* - WINDOWPLACEMENT posInfo; - posInfo.length = sizeof(WINDOWPLACEMENT); - ::GetWindowPlacement(_pPublicInterface->getHSelf(), &posInfo); + nppGUI._isMaximized = IsZoomed(_pPublicInterface->getHSelf()) != 0; - nppGUI._appPos.left = posInfo.rcNormalPosition.left; - nppGUI._appPos.top = posInfo.rcNormalPosition.top; - nppGUI._appPos.right = posInfo.rcNormalPosition.right - posInfo.rcNormalPosition.left; - nppGUI._appPos.bottom = posInfo.rcNormalPosition.bottom - posInfo.rcNormalPosition.top; - nppGUI._isMaximized = (IsZoomed(_pPublicInterface->getHSelf()) || (posInfo.flags & WPF_RESTORETOMAXIMIZED)); -*/ - // There is some discontinuity in position values that are coming from GetWindowPlacement when window - // is on secondary screen and Windows taskbar is on left side of the screen. Use GetWindowRect instead. - RECT pos; - ::GetWindowRect(_pPublicInterface->getHSelf(), &pos); + if(nppGUI._isMaximized) + { + // When window is maximized GetWindowPlacement returns window's last non maximized coordinates. + // Save them so that those will be used when window is restored next time. + WINDOWPLACEMENT posInfo; + posInfo.length = sizeof(WINDOWPLACEMENT); + ::GetWindowPlacement(_pPublicInterface->getHSelf(), &posInfo); - nppGUI._appPos.left = pos.left; - nppGUI._appPos.top = pos.top; - nppGUI._appPos.right = pos.right - pos.left; - nppGUI._appPos.bottom = pos.bottom - pos.top; + nppGUI._appPos.left = posInfo.rcNormalPosition.left; + nppGUI._appPos.top = posInfo.rcNormalPosition.top; + nppGUI._appPos.right = posInfo.rcNormalPosition.right - posInfo.rcNormalPosition.left; + nppGUI._appPos.bottom = posInfo.rcNormalPosition.bottom - posInfo.rcNormalPosition.top; + } + else + { + // There is some discontinuity in position values that are coming from GetWindowPlacement when window + // is on secondary screen and Windows taskbar is on left side of the screen. Use GetWindowRect instead. + RECT pos; + ::GetWindowRect(_pPublicInterface->getHSelf(), &pos); + nppGUI._appPos.left = pos.left; + nppGUI._appPos.top = pos.top; + nppGUI._appPos.right = pos.right - pos.left; + nppGUI._appPos.bottom = pos.bottom - pos.top; + } saveDockingParams(); return (NppParameters::getInstance())->writeGUIParams();