Flickering controls

I know this is an over-discussed topic and that there is a certain amount of flickering I need to live with.
What I’m looking for is ways to minimize it.

In my project I have a colored background in a container.
Then I have labels on top.
When I change the labels text the control (label) is shows a rectangle around it in (full control size) in the color of the window’s current background color.

I’m about to rewrite the handling so that it finds all the text changes and then applies them at once at the end of a method where a bunch of computation is done, but I’m afraid that the effort won’t solve much.
I fear this because if I put a break point in the function I can watch the label background color change and it freezes there while I have the break point in.

What best practices other than “don’t put labels on colored backgrounds” are there?
If I have to re-write as a canvas based control I will - I just don’t want to go to that effort now if I don’t. have to.

What is the ‘colored background’?
Is it a canvas?
or just the background color of the container?

Either way, replace your labels with code to use .drawstring and draw the words in the paint event.


I can recreate by doing graphics commands but again I’m trying to avoid it as I’ve spent a lot of time building these, and they work wonderfully on Mac.

Yeah, it’s nicer to develop on the Mac but it gives you a false sense of success.
It’s often better (at least on a regular basis) to develop on Windows until it looks right there.
The Mac always will.

1 Like


One thing you could try is using a canvas and on Windows, programmatically figure out where each of the labels are, draw the string to the canvas and then hide the label. Then if you make a change to a label, you just need to refresh the canvas and it should update automagically.

I could leave all the labels invisible and all refresh on the canvas. Pain would iterate the labels and draw their content.

Interesting idea.

you should be able to use something like this:

for each item in controls
    if item isa DesktopLabel then
        // draw onto the canvas
    end if

and I’m doing that already so that I can set the color to a specific color group (I had to make my color groups programmatically because they kept reverting to black - means I can’t set them in the IDE).

Thank, Greg.

I ended up just drawing in the parent container control’s pain event.
Works great.
It seems that since this works it could reveal a hint for how the Xojo engineers might fix the flicker themselves.

1 Like

Labels are one thing, interactive controls are a completely different beast.

1 Like

Yes, I get that.