Search code examples
delphibackgroundtransparencytmstms-web-core

How do I give a transparent background color for TWebPanel?


As the title states. I want to have a transparent TWebPanel component, meaning only the border should be visible.

So I've made a simple form with an image and a panel:

enter image description here

I want to be able to see the image behind the panel. Here's what I've tried:

  • I looked for a transparent property somewhere or any property that might help, but didn't see any.
  • I've tried to remove the Color property, by making it empty, but that results in an error '' is not a valid integer value.
  • I looked through the custom colour dialog and there doesn't seem to be an Alpha channel:

What are my options? How can I make the background of the panel transparent?


Solution

  • Ah. I found out you can assign the gcNull or clNone value to the Color property on the panel. That makes it transparent:

    TMS Web Project with image and panel

    Do note though that in design-time, it looks black when the gcNull value is assigned to Color:

    Delphi TWebPanel

    But rest assured that in run-time, it is definitely transparent and not black.


    And if you want the border to be transparent also, then you can just set the BorderStyle property to bsNone.