From f911b63a5ce5f952ed3ca85e565200f8ea207c7c Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 11 Feb 2013 23:42:10 +0000 Subject: [PATCH] =?UTF-8?q?[BUG=5FFIXED]=20(Author:=20Pekka=20P=C3=B6yry)?= =?UTF-8?q?=20Fix=20the=20problem=20of=20Window=20position=20not=20saved/r?= =?UTF-8?q?estored=20properly.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1021 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) 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();