From: Vadim Zeitlin Date: Wed, 17 Dec 2008 10:17:23 +0000 (+0000) Subject: don't hard code the menu bar height under WinCE (closes #10248) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c0a91b519da0364d32dcafa2d4259ca9ecff9e68 don't hard code the menu bar height under WinCE (closes #10248) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 01835e8797..c81d5c6573 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -434,19 +434,23 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) SetToolBar(toolBar); menubar->SetToolBar(toolBar); } - // Now adjust size for menu bar - int menuHeight = 26; - //When the main window is created using CW_USEDEFAULT the height of the - // is created is not taken into account). So we resize the window after - // if a menubar is present + // When the main window is created using CW_USEDEFAULT the height of the + // menubar is not taken into account, so we resize it afterwards if a + // menubar is present + HWND hwndMenuBar = SHFindMenuBar(GetHwnd()); + if ( hwndMenuBar ) { + RECT mbRect; + ::GetWindowRect(hwndMenuBar, &mbRect); + const int menuHeight = mbRect.bottom - mbRect.top; + RECT rc; - ::GetWindowRect((HWND) GetHWND(), &rc); + ::GetWindowRect(GetHwnd(), &rc); // adjust for menu / titlebar height rc.bottom -= (2*menuHeight-1); - ::MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); + ::MoveWindow(Gethwnd(), rc.left, rc.top, rc.right, rc.bottom, FALSE); } #endif