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

Posted by webmaster Guido on September 09, 2005

In Reply to: Changing button background color and/or flashing it posted by hallinl p12462 on September 08, 2005

: 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 standard Delphi method to make a button "flash" (such as for example Button1.Flash). But you could imitate flashing by showing and hiding the button's caption (text) every so many milliseconds, under program control. If you are interested in this, let me know and I'll figure out some source code :)

Second solution: imitate a colored button. Use a TPanel component instead, it also has OnClick, OnMouseDown and OnMouseUp events just like a button has, but it also has a Color property.
In the OnMouseDown event handler, change the panel's appearance: change the BevelOuter property to bvLowered, and restore it to bvRaised appearance when OnMouseUp comes. If you want to try this, let me know and I'll cook up some code :)

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

Related Articles and Replies


Delphi Forum