Re: Changing Delphi button background color and/or flashing it

Posted by webmaster Guido

In Reply to: Changing button background color and/or flashing it posted by hallinl

: I am wanting to change the background color of a "button" once it is clicked (to acknowledge the users click). I am currently changing the foreground/text color but the background color change would be more obvious!

: Also, is there an easy way to make the button flash?

Alas, you can't change the color of a Delphi button. Delphi's buttons have the same color as Windows' buttons. This color depends from the Windows version (XP, 2000, 98,...) and from what might have been changed by the user in Windows' "Display Properties".

There is no Delphi method to make a button "flash". But you could imitate flashing by showing and hiding the button's caption (text) every so many milliseconds, under program control.

Second solution: imitate (mimic) a colored button. Look here for an article about it.
Basically, you use a TPanel component, it also has OnClick, OnMouseDown and OnMouseUp events just like a button has, but it has a Color property that is missing in TButton.
In the OnMouseDown event handler, change the panel's appearance (change the BevelOuter property), and restore it when OnMouseUp comes.

Last possibility: get a custom button component that has a color property. There are several freeware colored buttons around on the web.


Crash Course Delphi   Database Tutorial   FAQ   Source Code   Tips   Forum