Recent

Author Topic: Setting Button Color Doesnt Work?  (Read 14168 times)

T-bear

  • Full Member
  • ***
  • Posts: 160
Setting Button Color Doesnt Work?
« on: April 05, 2011, 03:22:02 pm »
Hi again,  ::)

When i use this code to set the color of a button it doesn't work.
Code: [Select]
Buttons[Counter].Color   :=clBlue; //Button[Counter] is the button.

Does anyone know why this doesnt work?

Thanks!  :D

PS: I also tried to change the color in the objectinspector but that didnt work either.

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Setting Button Color Doesnt Work?
« Reply #1 on: April 05, 2011, 03:59:18 pm »
It works here. Linux+Qt.
So tell us your Lazarus version, your OS and widgetset etc.
Is it TButton, TBitBtn or TSpeedButton?
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Setting Button Color Doesnt Work?
« Reply #2 on: April 05, 2011, 04:01:47 pm »
Lazarus: 0.9.28.2 Beta
FPC: 2.2.4

Windows XP,
And its a normal TButton

Changing The Color of the text on the button doesnt work either, but all the other things work...  %)  :(  :o
« Last Edit: April 05, 2011, 04:27:51 pm by T-bear »

lainz

  • Guest
Re: Setting Button Color Doesnt Work?
« Reply #3 on: April 05, 2011, 05:05:28 pm »
Lazarus: 0.9.28.2 Beta
FPC: 2.2.4

Windows XP,
And its a normal TButton

Changing The Color of the text on the button doesnt work either, but all the other things work...  %)  :(  :o

This is because Windows Themes.

Zoran

  • Hero Member
  • *****
  • Posts: 1918
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Setting Button Color Doesnt Work?
« Reply #4 on: April 05, 2011, 08:31:19 pm »
Windows native button does not allow this.
It's documented in Wiki under "Things that will never be fixed":

http://wiki.lazarus.freepascal.org/Lazarus_known_issues_%28things_that_will_never_be_fixed%29#TButton.27s_and_TBitBtn.27s_color_cannot_be_changed

:(
« Last Edit: April 05, 2011, 08:33:31 pm by Zoran »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

lainz

  • Guest
Re: Setting Button Color Doesnt Work?
« Reply #5 on: April 05, 2011, 08:50:25 pm »
You can install customdrawn package, is in development but you can user TCDButton (custom drawn button) allow to change color and set some kind of gradients and different skins.

carlosmoura

  • Newbie
  • Posts: 4
Re: Setting Button Color Doesnt Work?
« Reply #6 on: June 03, 2020, 05:27:22 pm »
Only for TSpeedButton  (tested on Lazarus 2.0.6 & Windows 10)
(Object Inspector or code)
   1) SpeedButton1.Transparent := False;
   2) SpeedButton1.Flat := True;   
   3) SpeedButton1.Color := <any different from parent color>;
   
Code: Pascal  [Select][+][-]
  1. procedure Tform1.SpeedButton1Click(Sender: TObject);  
  2. begin
  3.     if SpeedButton1.color = clRed then
  4.         SpeedButton1.color := clBlue
  5.     else
  6.         SpeedButton1.color := clRed;    
  7. end;
  8.  
(Sorry my bad english...)
« Last Edit: June 03, 2020, 05:32:04 pm by carlosmoura »

 

TinyPortal © 2005-2018