diff --git a/docs/changes.txt b/docs/changes.txt index 24d04880af..2f8175fcad 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -135,6 +135,10 @@ wxMSW: - Correct coordinates of wxDropFilesEvent (Dmitriy Maksimov). - Fix handling of abandoned mutexes in wxMutex (David Heffernan). +wxMSW/CE: + +- Don't hardcode the menu bar height (Michele Spighi). + wxGTK: - Fixed printing to use fonts sizes adjustment consistent with wxMSW. diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 624dea66ae..24bc31cc24 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -425,19 +425,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