diff --git a/include/wx/msw/statusbar.h b/include/wx/msw/statusbar.h index 5f2760bd39..a503a8c1e4 100644 --- a/include/wx/msw/statusbar.h +++ b/include/wx/msw/statusbar.h @@ -72,6 +72,8 @@ protected: // implementation of the public SetStatusWidths() void MSWUpdateFieldsWidths(); + virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE; + // used by DoUpdateStatusText() wxClientDC *m_pDC; diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index adf9ec9b1a..607b82f320 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -335,6 +335,14 @@ void wxFrame::PositionStatusBar() //else: no adjustments necessary for the toolbar on top #endif // wxUSE_TOOLBAR + // GetSize returns the height of the clientSize in which the statusbar + // height is subtracted (see wxFrame::DoGetClientSize). When the DPI of the + // window changes, the statusbar height will likely change so we need to + // account for this difference. If not, the statusbar will be positioned + // too high or low. + int shOld; + m_frameStatusBar->GetSize(NULL, &shOld); + // Resize the status bar to its default height, as it could have been set // to a wrong value before by WM_SIZE sent during the frame creation and // our status bars preserve their programmatically set size to avoid being @@ -342,8 +350,9 @@ void wxFrame::PositionStatusBar() // this here, the status bar would retain the possibly wrong current height. m_frameStatusBar->SetSize(x, h, w, wxDefaultCoord, wxSIZE_AUTO_HEIGHT); - int sw, sh; - m_frameStatusBar->GetSize(&sw, &sh); + int sh; + m_frameStatusBar->GetSize(NULL, &sh); + h += shOld - sh; // Since we wish the status bar to be directly under the client area, // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index ad9b4eff96..52696769b3 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -166,7 +166,8 @@ bool wxStatusBar::SetFont(const wxFont& font) if (!wxWindow::SetFont(font)) return false; - if (m_pDC) m_pDC->SetFont(font); + if ( m_pDC ) + m_pDC->SetFont(m_font); return true; } @@ -256,6 +257,14 @@ void wxStatusBar::MSWUpdateFieldsWidths() delete [] pWidths; } +void wxStatusBar::MSWUpdateFontOnDPIChange(const wxSize& newDPI) +{ + wxStatusBarBase::MSWUpdateFontOnDPIChange(newDPI); + + if ( m_pDC && m_font.IsOk() ) + m_pDC->SetFont(m_font); +} + void wxStatusBar::DoUpdateStatusText(int nField) { if (!m_pDC)