Site icon Learn 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++,

[crayon-6762fe0407e54658918416/]

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.

[crayon-6762fe0407e61143626182/]

Here is a example form and colors.

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

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.

Exit mobile version