Suggestion for alternative for calculating text resize in TextArea

I use the graphics class to resize the text to fit within various windows the textarea. Currently I pass the area as an object to a method and resize the text there. I need a suggestion for an alternate process than resizing it in the object because it flashes on the screen while it is resizing.

I am told the Graphics class needs a control to do this resizing, so if there is a way to do this without a control, that would work.

I thought of creating a window strictly for making the calculations, but that seems impractical, because that means I’d need to keep this window active.

I also imagine I could have a TextArea off the window and use that for this calculation.

I also have not learned how to create anything by code, so that is a possibility.

Suggestions?

Use Window.BitmapForCaching to get a properly constructed HiDPI aware image/graphics object for the window on it’s current screen.
Using the text area coordinates, calculate the sizing of the text in the offscreen Graphics object from that picture.
Set the text sizing once you’ve calculated it.

Does that work out any better?

Thanks. I didn’t pay attention because it is for HIDPI.

That’s why you grab the Window.BitmapForCaching, the Picture you get from that will be properly configured. You may have to experiment with HiDPI vs non-HiDPI to ensure calculations are correct for both. Getting the graphics object will look something like this:

dim tpicWindowRep as Picture = self.BitmapForCaching
dim g as Graphics = tpicWindowRep.Graphics

Looks like you might have figured it out while I was working on that. I hope it helped and didn’t confuse.