From 989b0a249cf14eb4f420c14e01fa23c58b4e44ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Szil=C3=A1gyi?= Date: Thu, 9 May 2013 14:13:24 +0300 Subject: [PATCH] Fix centerWindow() when the taskbar is located along the top or left screen edge centerWindow() will not center the window correctly when the taskbar is located along the top or left screen edge. --- cocos2dx/platform/win32/CCEGLView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index ddc79748fa..4136694e6d 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -693,9 +693,9 @@ void CCEGLView::centerWindow() } GetWindowRect(m_hWnd, &rcWindow); - int offsetX = (rcDesktop.right - rcDesktop.left - (rcWindow.right - rcWindow.left)) / 2; + int offsetX = rcDesktop.left + (rcDesktop.right - rcDesktop.left - (rcWindow.right - rcWindow.left)) / 2; offsetX = (offsetX > 0) ? offsetX : rcDesktop.left; - int offsetY = (rcDesktop.bottom - rcDesktop.top - (rcWindow.bottom - rcWindow.top)) / 2; + int offsetY = rcDesktop.top + (rcDesktop.bottom - rcDesktop.top - (rcWindow.bottom - rcWindow.top)) / 2; offsetY = (offsetY > 0) ? offsetY : rcDesktop.top; SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER);