C++C++17ComponentsIntroduction to C++Language FeatureLearn C++

How To Change Background Color Of A Component In An FMX C++ App

How To Change Background Color Of A Component In An FMX C++ App

C++ Builder is the easiest and fastest C++ IDE for building professional applications with powerful GUI components like Memo, Edit, ListBox, StringGrid and many more. Each component can be ‘skinned’ with Styles to change their visual appearance. Styles are very powerful and because of this it can sometimes take a little to get used to how they work. In this post, we explain how to change background color of a component. Here is how you can do,

How can I change background color of a component using styles in an FMX app?

Syles are sets of graphical details that define the look and feel of an application visually and they are one of most beautiful and useful UI features of RAD Studio. Styles make your UI elements have a professionally designed appearance with minimum effort from you. Official Styles are designed by Embarcadero’s professional graphic designers. There are also other 3rd party Styles; also, users may generate their own styles. Styles are similar to themes in Windows or skins of old-style applications like WinAmp – but brought right up to date for the modern world.

In RAD Studio, Multi-Device C++ Builder FireMonkey Projects, using styles on your new projects is very easy. You design your application’s screens in normal ways with buttons, labels, edit boxes, memos, trackbars, panels, switches etc. These controls will automatically adopt whatever appearance is enabled by the chosen style. You can also add these Styles to your Old C++ Builder Projects or to Old C++ Builder Unit files. You just need a RAD Studio, C++ Builder version which supports styles. We highly recommend you use the latest RAD Studio or C++ Builder versions which have new features and improvements on Styles. Here is how you can use Styles.

In addition, you can create your custom styles in RAD Studio and C++ Builder. Here are two examples about Memo (TMemo) and Edit (TEdit) components.

How to change background color of an FMX component in C++ code?

Here is a simple function example to change background color of a component in C++,

Is there a full C++ example of how to change the background color of a component in FMX and C++?

In this example there are Memo, Edit, ComboBox, ListBox components and a Button component. You need to create a new C++ Builder Multi-Device application and then you should drag these components on your form.

You can choose your colors from here https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Colors_in_FireMonkey If you want to know more about colors in Modern C++ here are some examples of how to use RGB or ARGB colors in C++.

After that, you can modify your code as below. Here is a full C++ example of to change the background color of a component in an FMX C++ application.

Here is a example form and colors.

How To Change Background Color Of A Component In An FMX C++ App An example of changing colors

Note that, here we changed the Fill color of Form (TForm) via the Object Inspector panel in C++ Builder.

How To Change Background Color Of An Edit In An FMX C++ App C++ Builder logo

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise version.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?