Go Premium for a chance to win a PS4. Enter to Win


Changing The Colour Of A Component

Posted on 2006-10-21
Medium Priority
Last Modified: 2008-03-15
Is there an easy way to change the colour of a Delphi component when there isn't a Color property in the Object Inspector?

I have the TTrackbar component in mind (which looks awful when placed on a black form), but a method which could be applied regardless of the component would be useful.


Question by:tdk_man
  • 3
LVL 28

Expert Comment

ID: 17781595
As TTrackbar inherits the color of it's parent, the easiest way to do it would be to place the trackbar on a panel (e.g. the trackbar with alClient on a long narrow panel) and to give the panel the color you like.

Here's some code that exemplifies drawing a border in the trackbar:

Here you can use other system colors instead of COLOR_BTNFACE:
or declare a new color constant, e.g.:

procedure TForm1.TrackBarWndProc(var Message: TMessage);
NewColor:Cardinal = $00805C53;

and use it instead:
BtnFaceBrush := CreateSolidBrush(NewColor); //but then I'd change the name of the brush though...;)
LVL 28

Expert Comment

ID: 17781700
>the easiest way to do it would be to place the trackbar on a panel...

Just found an easier way:

LVL 28

Accepted Solution

TName earned 500 total points
ID: 17781710
No typecast required:


Author Comment

ID: 17783784
Thanks for the suggestions TName.

Changing the Brush colour works, but in doing so I have unfortunately discovered that I didn't have the problem I thought I had. Sorry about that.

What I hadn't realised was that it was the border around the component which was taking the colour of the background - I just thought it was transparent. I was therefore asking how to change the colour to one which it already was - if you see what I mean?... :)

So, realising this prior posting I would have asked a different question:

"If you drop a TTrackbar component onto a black form and the background becomes black you can't see the black tickmarks. Is there any way to change the colour of them so they are visible."

Actually the ability to change the colour of the trackbar groove and thumb would be nice too - but not really important.


Expert Comment

ID: 21133071
Forced accept.

EE Admin

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question