diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index fd0f63d801..ca5fd0c0e2 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -46,6 +46,7 @@ public: // accessors void SetLabel(const wxString& label); + bool SetFont( const wxFont &font ); // overriden base class virtuals virtual bool AcceptsFocus() const { return FALSE; } diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 82b2a21745..c4a61fd113 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -86,7 +86,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, SubclassWin(m_hWnd); - SetFont(parent->GetFont()); + wxControl::SetFont(parent->GetFont()); SetSize(x, y, width, height); return TRUE; @@ -148,6 +148,22 @@ void wxStaticText::SetLabel(const wxString& label) } } + +bool wxStaticText::SetFont(const wxFont& font) +{ + bool ret = wxControl::SetFont(font); + + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + } + + return ret; +} + + long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // Ensure that static items get messages. Some controls don't like this