From cd02204419c6b711efc7e77525334c6537eade85 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Sat, 14 Dec 2013 18:03:44 +0800 Subject: [PATCH] TortoiseGitMerge: Fix a maximizing problem maximizing on a non-primary monitor Based on TortoiseSVN revision 25046, 25047 Signed-off-by: Sup Yut Sum --- src/TortoiseMerge/MainFrm.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/TortoiseMerge/MainFrm.cpp b/src/TortoiseMerge/MainFrm.cpp index d8b0fd0cb..c2eb27154 100644 --- a/src/TortoiseMerge/MainFrm.cpp +++ b/src/TortoiseMerge/MainFrm.cpp @@ -1083,17 +1083,42 @@ void CMainFrame::OnSize(UINT nType, int cx, int cy) m_bCheckReload = false; CheckForReload(); } +#if _MSC_VER < 1800 // workaround for ribbon interface when the task bar is on the left or top + // The bug has been fixed in VS2013 + // http://connect.microsoft.com/VisualStudio/feedback/details/791229/cmfcribbonbar-app-does-not-maximize-correctly-if-windows-7-taskbar-is-docked-on-left if (nType == SIZE_MAXIMIZED) { - WINDOWPLACEMENT wp; - GetWindowPlacement(&wp); - if (wp.ptMaxPosition.x || wp.ptMaxPosition.y) + HMONITOR hMon = MonitorFromWindow(this->m_hWnd, MONITOR_DEFAULTTONEAREST); + MONITORINFOEX mix; + mix.cbSize = sizeof(MONITORINFOEX); + bool primary = true; // assume primary monitor + CRect rect(0, 0, 0, 0); + if (GetMonitorInfo(hMon, &mix)) { - wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; - SetWindowPlacement(&wp); + primary = (mix.dwFlags == MONITORINFOF_PRIMARY); + rect = mix.rcWork; + } + else + { + ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0); + } + if (primary) + { + WINDOWPLACEMENT wp; + GetWindowPlacement(&wp); + if (wp.ptMaxPosition.x || wp.ptMaxPosition.y) + { + wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; + SetWindowPlacement(&wp); + } + } + else + { + MoveWindow(rect); } } +#endif } void CMainFrame::OnViewWhitespaces() -- 2.11.4.GIT