Recent

Author Topic: Bug? tButton can not be made transparent?  (Read 3571 times)

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Bug? tButton can not be made transparent?
« on: May 16, 2012, 03:12:04 am »
I am unable to make tButton transparent by setting the color to clNone so that a label under it shows through.  (and no, I cannot just combine the button and label into the button as in some modes of the program the button will be hidden and the label will need to be visible.)

Is this a bug or is this due to the button widget as implemented on Windows?

Laz: 1.1-36568-2.6.1, win32-Vista

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Bug? tButton can not be made transparent?
« Reply #1 on: May 16, 2012, 07:38:32 am »
It is just out of scope for TButton. It does not support this and is not supposed to. Also clNone is also not transparent, it is just black as far as I know.

Also TWinControl descendents cannot have alpha transparency in the LCL. If you really need real transparency over a non-uniform background you need to write your own class. Or just use TLabel + it's OnClick event.

If you don't need that real transparency another option would be to create a new drawer for CustomDrawn and use this drawer together with TCDButton. It should be enough to copy the button drawing code from the default drawer and remove all code except the label and add a background drawing. The background will appear transparent when it has the same color as the parent control. http://wiki.lazarus.freepascal.org/Lazarus%20Custom%20Drawn%20Controls

 

TinyPortal © 2005-2018