UseOldRenderer replacement

I’ve got a project that’s plenty old that I recently updated to 2022R3.2 It has a problem with two controls that are painted in there to have a linkable (clickable), text right justified button that doesn’t look like a button. This control is ultimately based on canvas, so it’s doing some fancy rendering and sizing and that kind of thing.

The old code used UseOldRenderer and it worked fine there.

In this thing, of course, you can’t use that so on Windows, this gives the text in the correct position but a white rectangle to the left of it. On Mac (either flavor) this gives left justified text. Until you mouse into the area when it repaints in the correct spot and colors. On Windows you have to mouse into the control itself while on Mac you can mouse into most anywhere near it before it repaints correctly.

Once repainted, it is always correct.

So, what’s the replacement for UseOldRenderer that gives the correct paint the first time?

the circled thing is what moves left to right… it’s implemented as a canvas that gets written on
image

On a Mac that “add” is sitting next to “reports” when it first renders and as soon as you mouse near it, it moves to where it’s supposed to be (as shown here)

There’s nothing obvious that jumps to mind related to UseOldRenderer that might be causing this. Can you show us the code that draws this image?

The replacement for UseOldRenderer is AntiAliased, with the value inverted:

g.UseOldRenderer=True
equals
g.AntiAliased=False

whatever is going on here, this doesn’t influence it. Good theory tho.

Can you create a sample project that shows the problem?
Maybe that way someone can take a look and see if something can be done.

I thinking that this doesn’t actually have anything to do with this particular Rendering flag but with some sort of timing change where the draws aren’t being fired or are being fired in some sort of changed order or something that is preventing correct first render. Subsequent renders are fine, just the first render is bad.

We just ran into something interesting with Win10 and 11… This version of Xojo (2022R3.1) is MUCH slower than Xojo 2018 in rendering complex, multi layered windows. So much so that it looks like an HTML page as it renders; things painting in and moving and all kinds of things like that. Don’t see that exact problem on Mac but I can’t use Xojo 2018 projects on OS13.x so I have to change up on Mac at least.

So I’ve worked around my problem here which appears to involve timing of events. At least on MAC.

Old code was right justifying the text by doing this in the paint event:
g.DrawString pText, 0, y

me.Left = me.Left + (me.Width - CType(g.StringWidth(me.pText), Integer))
me.Width = CType(g.StringWidth(me.pText), Integer)

So what I ended up doing was to just render the text in the right spot rather than screwing around with resizing controls:

g.DrawString pText, me.Width - TxtWidth, y

which gets it right the first time.

1 Like