Label and Canvas Transparency fail on Windows 11

Hi Folks,

Does anyone have a tip on getting canvases and labels to be transparent in 21r3.1 on Windows 10/11?

I have tried turning Transparency on and off (and back on again :slight_smile: ) - no joy. Apparently, “Use GDI+” is no longer an option.

Things that look great on Linux and macOS are failing big time on Windows.

are you using this new Desktop… Controls?
i have a app with transparent labels on a window that works at windows 10 and xojo21r3

No - created in 18r3.2 and being edited and compiled in 21r3.1

you could backup this project and try a copy with
menu project / update controls to api 2
or context menu at window/control “update to desktop …”

When Xojo switched graphics on MS-Windows from GDI+ to Direct2D they trashed some of the existing functionality so I wouldn’t be surprised if you are suffering from that.

It might be useful if you can share some screen shots and a better description of what the problem is.

1 Like

On older versions, you can replace labels with a call to .drawstring in the window’s Paint event.
You won’t get events for a control, done that way, but they will be properly ‘transparent’

A thought:
You can simulate label events by adding code in the window mousedown events and so on, checking whether the mouse went down within the ‘bounds’ of the text you drew.

That’s no longer possible?

Window has a Paint event, DesktopWindow has a paint event.
Both have a graphics parameter.
Why would this not be possible?

Because you said it was on older versions. My question came from this part of your sentence.
But that’s a detail.

1 Like

There is no more “transparent” on Controls for TargetWindows. In order to avoid flickering, Xojo uses “pseudo transparency”. Try searching for “pseudo transparency” and you should find quite some forum topics about that. One link: Text label on rectangle interface quirks on Windows, but not Mac

A short answer:

  • the Background will be the Color of the Color of it’s “parent”. Make sure the parent is correctly recognized in the Layout Editor.
  • a Label on a Canvas: bad idea. .DrawString in the Canvas, but don’t put a Label on a Canvas
  • same for Canvas-on-Canvas

Might need some refactoring should you have “overlapping controls”… but is worth it on all platforms.

Thanks for explaining this. I can stop banging my head against the wall now. I was trying to get a transparent canvas image to span over two different color rectangles. One black, one grey, and the canvas background only chose to be black. Guess that isn’t going to work. Time to modify my layout.

1 Like