Author Topic: flicker when I rezize the Build log control(TextCtrlLogger) issue  (Read 831 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6200
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Today, I noticed that when I resize the "Build log" panel, I see this window get flickered a lot. When I drag the panel edge between our cbEditor window and the Build log, I don't see the cbEditor get flickered.

So, I prepared a patch, and it looks like with this patch, the "Build log"'s flicker get reduced, can you try this patch? Or maybe there are many other method to handle this.

Code
From 015270b1dc35f3020e549c0e7af310fcb682b66d Mon Sep 17 00:00:00 2001
From: asmwarrior <hidehide@hidehide.com>
Date: Wed, 25 Mar 2026 18:08:38 +0800
Subject: [PATCH] text logger: try to enable the double buffering to stop the
 flickering

---
 src/sdk/loggers.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/sdk/loggers.cpp b/src/sdk/loggers.cpp
index f3ec29f8d..25f8d5c18 100644
--- a/src/sdk/loggers.cpp
+++ b/src/sdk/loggers.cpp
@@ -169,6 +169,17 @@ wxWindow* TextCtrlLogger::CreateControl(wxWindow* parent)
 {
     if (!control)
         control = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_NOHIDESEL | wxTE_AUTO_URL);
+
+    // Enable double buffering to stop flickering
+    if (control)
+    {
+        control->SetDoubleBuffered(true);
+        // In your event table or Bind calls:
+        control->Bind(wxEVT_ERASE_BACKGROUND, [](wxEraseEvent& event) {
+            // Do nothing here to skip the default background clearing
+        });
+    }
+
     return control;
 }
 

Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1848
Re: flicker when I rezize the Build log control(TextCtrlLogger) issue
« Reply #1 on: March 25, 2026, 02:03:27 pm »
Which version of wxWidgets are you using?

Double buffering behaviour has been modified around wx3.3.2, see for example Revert "Enable double buffering for all generic windows in wxMSW"

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6200
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: flicker when I rezize the Build log control(TextCtrlLogger) issue
« Reply #2 on: March 25, 2026, 03:07:10 pm »
Which version of wxWidgets are you using?
I'm using the latest wx 3.3.2 release.


Quote
Double buffering behaviour has been modified around wx3.3.2, see for example Revert "Enable double buffering for all generic windows in wxMSW"

So, the double buffering is disabled by default in 3.3.2 for the wxTextCtrl class?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1848
Re: flicker when I rezize the Build log control(TextCtrlLogger) issue
« Reply #3 on: March 25, 2026, 04:17:58 pm »
Quote
So, the double buffering is disabled by default in 3.3.2 for the wxTextCtrl class?

I do not know, try calling control->IsDoubleBuffered() after loggers.cpp:171. With 3.2.10 it returns false, and the control does not flicker (in fact, it is not redrawn until I release the mouse button).

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6200
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: flicker when I rezize the Build log control(TextCtrlLogger) issue
« Reply #4 on: Yesterday at 01:38:18 pm »
 I wrote some code snippet like this

Code
    if (control)
    {
        // Check if it's already enabled (either by default or previously set)
        if (!control->IsDoubleBuffered())
        {
            control->SetDoubleBuffered(true);
        }

        // Always a good idea to bind this if you're still seeing "white flashes"
        control->Bind(wxEVT_ERASE_BACKGROUND, [](wxEraseEvent& event) {
            // Leave empty to prevent background clearing
        });
    }

I set the breakpoint inside the "if (!control->IsDoubleBuffered())" clause, and I see it hit there. So, under wx 3.3.2, the double buffer is not enabled by default, so calling the "control->SetDoubleBuffered(true);" will enable it.


Quote
in fact, it is not redrawn until I release the mouse button
OK, I see such option, it is an option for Windows OS's graphics system to reduce the flicker.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.