From 5ab37c86b22fd6c26fb19f5379b8c14653e27688 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 17 Oct 2012 16:50:07 +0800 Subject: [PATCH] Fix a bug about calculating client area on win32. --- cocos2dx/platform/win32/CCEGLView.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index ec3442fd6f..dcd1fb679a 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -302,8 +302,9 @@ bool CCEGLView::Create() wszBuf, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position - 100, // Window Width - 100, // Window Height + //TODO: Initializing width with a large value to avoid get a wrong client area by 'GetClientRect'. + 1000, // Window Width + 1000, // Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance @@ -582,6 +583,11 @@ void CCEGLView::setIMEKeyboardState(bool /*bOpen*/) void CCEGLView::setMenuResource(LPCWSTR menu) { m_menu = menu; + if (m_hWnd != NULL) + { + HMENU hMenu = LoadMenu(GetModuleHandle(NULL), menu); + SetMenu(m_hWnd, hMenu); + } } void CCEGLView::setWndProc(CUSTOM_WND_PROC proc) @@ -631,7 +637,7 @@ void CCEGLView::resize(int width, int height) #endif } - AdjustWindowRectEx(&rcClient, GetWindowLong(m_hWnd, GWL_STYLE), false, GetWindowLong(m_hWnd, GWL_EXSTYLE)); + AdjustWindowRectEx(&rcClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE)); // change width and height SetWindowPos(m_hWnd, 0, 0, 0, width + ptDiff.x, height + ptDiff.y,