Recent

Author Topic: [Solved] How to Adjust Checkbox Text Color?  (Read 2019 times)

loaded

  • Hero Member
  • *****
  • Posts: 870
[Solved] How to Adjust Checkbox Text Color?
« on: February 25, 2022, 07:19:18 am »
Hi All,
I saw different solutions in my research and I wanted to ask here, maybe it can be solved in a very simple way.
The Color option in the font property of the checkbox does not work. Is there a setting to make it work? Respects.
« Last Edit: February 26, 2022, 11:05:06 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

balazsszekely

  • Guest
Re: How to Adjust Checkbox Text Color?
« Reply #1 on: February 25, 2022, 10:12:25 am »
TCheckbox is just a wrapper around the standard OS checkbox, therefor the color cannot be changed, not easily at least. You have several options:
1. Use a custom component instead
2. Try to catch LM_PAINT and do the drawing yourself
3. Disable themes
4. Delete the checkbox caption and add a label after it. I think this is the least painful method. You can even create a small component(TPanel + TDBCheckbox + TLabel) if you need to re-use a colored checkbox multiple times in your application

loaded

  • Hero Member
  • *****
  • Posts: 870
Re: How to Adjust Checkbox Text Color?
« Reply #2 on: February 25, 2022, 10:29:06 am »
My Dear Master Getmem, yes I can try these.
But I am using TDBCheckBox in my project. The reason I gave an example from TCheckBox was that they were descended from the same ancestor.
It's not essential for me to change the color, but it would be nice if it could be done simply.
If I apply the above solution, I think I will also have to deal with the database. I will try your suggestions at a suitable time (By the way, the to-try list has increased so much!!! )  %)
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

speter

  • Sr. Member
  • ****
  • Posts: 367
Re: How to Adjust Checkbox Text Color?
« Reply #3 on: February 26, 2022, 10:48:25 am »
You could maybe have no caption with the checkbox and place a label next to it (with coloured text)...

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

loaded

  • Hero Member
  • *****
  • Posts: 870
Re: How to Adjust Checkbox Text Color?
« Reply #4 on: February 26, 2022, 11:02:49 am »
Thanks a lot for the reply, speter.
Pretty simple solution, I don't know why I didn't think of this before.  8)

4. Delete the checkbox caption and add a label after it. I think this is the least painful method. You can even create a small component(TPanel + TDBCheckbox + TLabel) if you need to re-use a colored checkbox multiple times in your application

The master said but I did not understand ;D
« Last Edit: February 26, 2022, 09:01:30 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

loaded

  • Hero Member
  • *****
  • Posts: 870
Re: [Solved] How to Adjust Checkbox Text Color?
« Reply #5 on: February 26, 2022, 09:07:44 pm »
Yes, this is exactly the solution I wanted, it's number ten, thank you very much jamie.

I don't know why, after your messages, I understand master GetMem better. When I read Master GetMem 's message again

2. Try to catch LM_PAINT and do the drawing yourself
Apperantly ! The Master meant this in his statement.
So, what he said is right, congratulations.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018