For some reason, transparent controls on a form turn opaque on some computers. I got reports of it happening on an "Acer Netbook" and a "Thinkpad x600". The application is built with Delphi 2007.
This is what it looks like: link
While it should look like this: link
The opaque controls on the form are TLabels and TStaticTexts.
(I use TStaticText controls to define clickable areas because mouse messages to handle-less controls (like Labels) go to the WM_NCHITTEST handler. The "button" on the bottom is black because I accidentally set its color to clNone, although it shouldn't be visible at all.)
Why does it happen and how to prevent this (other than workarounds like rendering the text to the background image)?
Edit: I managed to reproduce the problem on my laptop, which is running Windows XP in 32-bit color, and using certified ATI drivers.
Is there a TImage between the TLabel and the form? If that is the case then set the form's color to black. When you set a TLabel to transparent it draws it on its parent, and a TImage cannot have child controls. In effect it is rendering the color of the form onto the label since the form is the parent.
Two other possible workarounds include paining the image directly onto the form (not using a TLabel) but I don't know if that would work. Another would be to create your own image control that descends from TWinControl (instead of TGraphicControl) and that can contain child controls. YMMV on those solutions though.
I suspect the reason it doesn't work on some machines is the underlying Windows API library is different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With