From 4e2684c1557d980ae5d8a56a74e3a8894c3b9671 Mon Sep 17 00:00:00 2001 From: sbrowne Date: Sun, 16 Jul 2017 02:28:16 +0200 Subject: [PATCH] Avoid flicker when size of wxStaticText doesn't change in wxMSW Don't do anything if wxStaticText::DoSetSize() is called with the same size as the control already uses, this only results in flicker. Closes #17075. --- src/msw/stattext.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 1b532ce62a..3d0d074023 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -120,9 +120,17 @@ wxSize wxStaticText::DoGetBestClientSize() const void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags) { + // Keep track of the size before so we can see if it changed + const wxSize sizeBefore = GetSize(); + // note: we first need to set the size and _then_ call UpdateLabel wxStaticTextBase::DoSetSize(x, y, w, h, sizeFlags); + // Avoid flicker by not refreshing or updating the label if the size didn't + // change. + if ( sizeBefore == GetSize() ) + return; + #ifdef SS_ENDELLIPSIS // do we need to ellipsize the contents? long styleReal = ::GetWindowLong(GetHwnd(), GWL_STYLE);