Science, Tech, Math › Computer Science TColorButton With Color Properties Make Your Own Button Component With Custom Colors Share Flipboard Email Print Topic Images, Inc./Topic Images/Getty Images Computer Science Delphi Programming Delphi Tutorials Advanced PHP Programming Perl Python Java Programming Javascript Programming C & C++ Programming Ruby Programming Visual Basic View More By Zarko Gajic Zarko Gajic Twitter Computer Science Expert MSCS, Computer Science, University of Osijek Zarko Gajic is experienced in SQL and has working knowledge of DB systems such as MS SQL Server, Firebird, Interbase, and Oracle. He is also proficient in XML, DHTML, and JavaScript. Learn about our Editorial Process Updated on April 23, 2019 The background color of a TButton is controlled by Windows, not Delphi. TButton is a simple wrapper around the standard Windows button, and Windows does not allow it to be colored except by choosing the colors in Control Panel. This means you can not set the background color of a TButton, nor you can change the background color of TBitBtn or TSpeedButton. Since Windows insists on doing the background coloring with clBtnFace, the only way to change it is to draw the button yourself by making an owner-drawn button component. TColorButton Source Code The TColorButton adds three new properties to the standard TButton: BackColor - Specifies the background color of the buttonForeColor - Specifies the color of the button text. Note that this "overrides" the Font.Color propertyHoverColor - Specifies the color used to paint the button's background when the mouse hovers over the button. Here's how to set color-related properties of the TColorButton at runtime: ColorButton1.BackColor := clOlive; //background ColorButton1.ForeColor := clYelow; //text ColorButton1.HoverColor := clNavy; //mouse over Installing Into a Component Palette The TColorButton comes as a single unit file with the .PAS file extension. After downloading the component, you need to install the source component into an existing package. Cite this Article Format mla apa chicago Your Citation Gajic, Zarko. "TColorButton With Color Properties." ThoughtCo, Jul. 31, 2021, thoughtco.com/source-code-for-tcolorbutton-4077901. Gajic, Zarko. (2021, July 31). TColorButton With Color Properties. Retrieved from https://www.thoughtco.com/source-code-for-tcolorbutton-4077901 Gajic, Zarko. "TColorButton With Color Properties." ThoughtCo. https://www.thoughtco.com/source-code-for-tcolorbutton-4077901 (accessed May 29, 2023). copy citation