Recent

Author Topic: Get button face color at runtime  (Read 636 times)

Graham1

  • Jr. Member
  • **
  • Posts: 64
Get button face color at runtime
« on: July 28, 2024, 04:20:45 am »
I know the color of the button face is supposed to be clBtnFace but on my PC that gives $F0F0F0. When I look at the actual color of my buttons when I run my program it's $E1E1E1. I assume my theme is messing things up.

How can I find the actual color used by the button face at runtime?
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

Rizzz

  • New member
  • *
  • Posts: 7
Re: Get button face color at runtime
« Reply #1 on: August 01, 2024, 11:34:17 am »
To find the actual color used by the button face at runtime, you can use the GetSysColor function in your code to retrieve the system color for COLOR_BTNFACE. This will give you the color currently being used, considering any theme or visual style applied to your system. Here's a sample code snippet in C++:

Code: C  [Select][+][-]
  1. COLORREF btnFaceColor = GetSysColor(COLOR_BTNFACE);
  2.  
This will return the actual color being used, so you can compare it to the expected value.

Graham1

  • Jr. Member
  • **
  • Posts: 64
Re: Get button face color at runtime
« Reply #2 on: August 04, 2024, 04:29:11 am »
Thank you! With that information I was able to find that it's included in LCLIntf, and there is an example as the "Show System Colors" button in:

C:\<Lazarus folder>\examples\canvas_test

And that handles both Windows and Linux, I think.

Thanks again.

Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

 

TinyPortal © 2005-2018