Recent

Author Topic: Changing TButton's color anyone? This should be easy!  (Read 9696 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Changing TButton's color anyone? This should be easy!
« on: August 30, 2016, 09:56:39 pm »
Windows 10
Lazarus 1.6
Changing the color of a TButton face does nothing.
Got paranoid so I tried on two different machines. Same diff.

This must be simple. What am I missing?

balazsszekely

  • Guest
Re: Changing TButton's color anyone? This should be easy!
« Reply #1 on: August 30, 2016, 10:03:43 pm »
Quote
@EganSolo
What am I missing?
TButton is just a wrapper around the standard Windows button, therefor the color cannot be changed.

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Re: Changing TButton's color anyone? This should be easy!
« Reply #2 on: August 30, 2016, 10:14:52 pm »
I must be missing something. The color in the TButton in Delphi can be changed. Is there a different button whose color could be changed? By the way the same holds true for the color of the font. I can't change that either.


crack81

  • New Member
  • *
  • Posts: 12

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Changing TButton's color anyone? This should be easy!
« Reply #4 on: August 30, 2016, 11:30:48 pm »
Switch of theming (Project options->Application->uncheck "Use manifest file to enabe themes"?

Bart

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Changing TButton's color anyone? This should be easy!
« Reply #5 on: August 30, 2016, 11:39:07 pm »
Switch of theming (Project options->Application->uncheck "Use manifest file to enabe themes"?

Bart

That doesn't works for me with TButton...

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Changing TButton's color anyone? This should be easy!
« Reply #6 on: August 31, 2016, 12:19:16 am »
That doesn't works for me with TButton...

Sorry, that was for TButton's font color...

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Changing TButton's color anyone? This should be easy!
« Reply #7 on: August 31, 2016, 08:05:22 am »
I must be missing something. The color in the TButton in Delphi can be changed. Is there a different button whose color could be changed? By the way the same holds true for the color of the font. I can't change that either.
No, the VCL button's color can NOT be changed in Delphi. That is nonsense.
The font color can only be changed.
Maybe you are confused with FireMonky that is a fancy theming engine and where buttons can change color.
If you want a button that can change color, use a TBitButton.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

balazsszekely

  • Guest
Re: Changing TButton's color anyone? This should be easy!
« Reply #8 on: August 31, 2016, 08:21:27 am »
Quote
@Thaddy
If you want a button that can change color, use a TBitButton.
Unfortunately the same applies to TBitButton too(under windows), so the color cannot be changed. Both are inherited from TCustomButton:
     TBitBtn-->TCustomBitBtn->TCustomButton
     TButton-->TCustomButton

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Changing TButton's color anyone? This should be easy!
« Reply #9 on: August 31, 2016, 04:00:18 pm »
Welcome to the issues/limitations I experienced 11 years ago (circa 2005) with LCL. Soon afterwards fpGUI Toolkit was born.  :)

Bottom line is, if you want your application to be themed different to the OS default theme, then don't use LCL controls that maps to native OS controls. Use custom drawn widgets only or 100% custom drawn toolkits like fpGUI and MSEgui.
« Last Edit: August 31, 2016, 06:08:40 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Changing TButton's color anyone? This should be easy!
« Reply #10 on: August 31, 2016, 04:53:27 pm »
You can do this in the LCL with the Lazarus Custom Drawn Controls: http://wiki.freepascal.org/Lazarus_Custom_Drawn_Controls

Just write a new drawer for the button and use any color you want. Use the existing drawers as an example.

This is all part of the LCL since years.

What Graeme says is not true (and in the future I might delete such misleading messages, please don't persist in this behavior Graeme).
« Last Edit: August 31, 2016, 04:56:06 pm by felipemdc »

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Changing TButton's color anyone? This should be easy!
« Reply #11 on: August 31, 2016, 05:19:07 pm »
And you can use TBCButton that comes with BGRAControls:
http://wiki.lazarus.freepascal.org/BGRAControls#BCButton

There is no need to create a drawer or install a toolkit. Just change the properties of the control and that's all.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Changing TButton's color anyone? This should be easy!
« Reply #12 on: August 31, 2016, 05:57:37 pm »
What Graeme says is not true...
Felipe, I amended my original message to be more clear about what I mean (reading it again I see I was a bit vague). To be clear, LCL components that map to native OS widgets cannot be themed differently to the OS theme (for example: TButton). Yes you can use LCL Custom Drawn widgets (like TStringGrid, TBitBtn etc. if they support themeing), you can also use the LCL-CustomDrawn widgetset. The latter is unfortunately not nearly ready for production use. A lot of basic functionality is still missing from the LCL-CustomDrawn widgetset.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Changing TButton's color anyone? This should be easy!
« Reply #13 on: August 31, 2016, 06:01:37 pm »
There is no need to create a drawer or install a toolkit. Just change the properties of the control and that's all.
From how I understood the origin authors statement... He's asking about themeing in general. I don't know if he was only talking about TButton - if so, then yes your statement is correct. If he was referring to themeing ability of all components in the LCL, then BGRAControls is not an solution either, because BGRAControls doesn't duplicate all LCL components available. 100% Custom Drawn toolkits is your only answer at that point.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Re: Changing TButton's color anyone? This should be easy!
« Reply #14 on: August 31, 2016, 07:26:36 pm »
Thank you everyone for your assistance. I haven't been in Delphi for a few years now, so I take it I wasn't using TButton then  :-\

1. Use TCustomButton from the Cutsom Drawn Controlhttp://wiki.freepascal.org/Lazarus_Custom_Drawn_Controls: Great start. Unfortunately, I couldn't find a way to customize the bevels and the edges.

2. Use fpGui or MSEGui. Both are great suggestions and are worth every consideration. Unfortunately, I've got too much invested already in this app to move over right now. Maybe later.

3. Use BCRA: It's a bit overkill for someone who just wanted to change the color of a button's face. On the other hand, its great for theming. I wasn't planning to theme my app but I'll be doing that now. I've toyed with it over the last few days and I'm getting the hang of it.

So, once more, thank you all for your support and your help. I would suggest though (and I'll add it as a suggestion) to turn the Color of a TButton int a read-only property, but come to think of it, the object inspector does not support read-only properties, does it now? But that's a question for another day.  :)


 

TinyPortal © 2005-2018