Routines Path

What Is An Implicitly-defined Copy Assignment Operator In C++?

In C++ programming language, Object-Oriented Programming (OOP) is very widely used as a way to work on data functions in a way that helps represent the real world in an abstract manner. Classes and Objects are the best way to work on properties and methods. In a modern C++ Compiler, one of the OOP features is copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain an implicitly-defined copy assignment operator in C++ with examples. What are classes and objects in C++? Classes are defined in C++ using keyword class followed by the name of the class. Classes are the blueprint for the objects and they are user-defined data types that we can use in our program, and they work as an object constructor. Objects are an instantiation of a class, In C++ programming, most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class Tmyclass {           public:       std::string str; };   then we can create our objects with this Type of myclass as shown below. What is an implicitly-defined copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class, struct, or union that is copy assignable (that you can copy with the = operator symbol), it has a default copy assignment operator. The implicitly-defined copy assignment operator is defined If neither deleted nor trivial. That means this operator has a function body which is generated and compiled. This is called as Implicitly-defined copy assignment operator. In C++, T represents a literal type, it can be function, class type (class, struct, union object types), fundamentals type (void, bool, char, wchar_t), compound types (reference, pointer, array, function, enumeration). Since C++11,  if a class type has a user-declared destructor or user-declared copy constructor, the implicitly-defined copy assignment operator is deprecated. The implicitly-defined copy assignment operator for a class T is constexpr if, In general, for any non-static data member of type T  Since C++14, the Implicitly-defined copy assignment operator is used with a type T Since C++23, the assignment operator selected to copy each direct base class subobject is a constexpr function Since C++23, the implicitly-defined copy assignment operator for a class T is constexpr. What are the declaration and definition of a class? A declaration declares a unique name for the entity, along with information about its type (a type, class, struct, union) and other characteristics (parameters, options, base of it, etc.). In C++ all types, classes, structs, unions must be declared before they can be used. A definition provides the compiler with all the information it needs to generate machine code when the entity is used later in the program. The definition means this operator has a function body which is generated and compiled. Here is a simple syntax for default copy assignment operator with default option;   class_name & class_name :: operator= ( const class_name& ) = default;   here is a declaration example in a class,   Tmyclass& operator=( const Tmyclass& other) = default; // Default Copy Assignment Operator   here is a definition example including declaration,     Tmyclass& operator=( const Tmyclass& other) // declaration   {    // definition        // definition   }    // definition   now let’s see what is implicitly-defined copy assignment operator with a simple […]

Read More

What is Implicitly-declared Copy Assignment Operator In C++?

In C++ programming language, Object-Oriented Programming (OOP) is a good way to represent and manipulate data, and work with functions in memory. Classes and Objects are the best way to work on properties and methods. In a modern C++ Compiler, one of the OOP features is the copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain why we mean by an implicitly-declared copy assignment operator in C++ along with some examples. What are classes and objects in C++? Classes are defined in C++ using keyword class followed by the name of the class. Classes are the blueprint for the objects, and they are user-defined data types that we can use in our program, and they work as an object constructor. Objects are an instantiation of a class, In another term. In C++ programming, most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below,   class Tmyclass {           public:       std::string str; };   then we can create our objects with this Type of myclass as below, What is an implicitly-declared copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class, struct, or union that is copy assignable (that you can copy with the = operator symbol), it has a default copy assignment operator. In modern C++, the compiler declares an inline copy assignment operator as a public member of the class. This is called as Implicitly-declared copy assignment operator. This operator may have two different forms, with const T& and T& as below,   T& T::operator=(const T&)   and, These may depends on the parameters used in assignment operator. Note that a class may have  multiple copy assignment operators. We can force the generation of the implicitly declared copy assignment operator with the  default keyword, if there are any defined copy assignment operators. What is the declaration and definition of a class? A declaration declares a unique name for the entity, along with information about its type (a type, class, struct, union) and other characteristics (parameters, options, base of it, etc.). In C++ all types, classes, structs, unions must be declared before they can be used. A definition provides the compiler with all the information it needs to generate machine code when the entity is used later in the program. The definition means this operator has a function body which is generated and compiled. Here is a simple syntax for the implicitly-declared copy assignment operator, which is also default copy assignment operator with default option;   class_name & class_name :: operator= ( const class_name& ) = default;   here is a declaration example in a class,   Tmyclass& operator=( const Tmyclass& other) = default; // Default Copy Assignment Operator   Here is a definition example including declaration.     Tmyclass& operator=( const Tmyclass& other) // declaration   {    // definition        // definition   }    // definition   Now, let’s see what is implicitly-declared copy assignment operator with a simple example. Is there an example to implicitly-declared copy assignment operator in C++? Let’s give a simple C++ example to implicitly-declared copy assignment operator which is copy assignment operator with default option. Let’s assume that we have TmyclassA as a base class and […]

Read More

What Is A Forced (Default) Copy Assignment Operator In Modern C++

In the C++ programming language, Object-Oriented Programming (OOP) is a good way to represent data and organize the functionality of your code into logical groups. Classes and Objects are the best way to work on properties and methods. One of the features of OOP IDE is copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain the use of a forced default copy assignment operator with C++ examples. What are classes and objects in C++? Classes are defined in C++ using keyword class followed by the name of the class. Classes are the blueprint for the objects, and they are user-defined data types that we can use in our program, and they work as an object constructor. Objects are an instantiation of a class. In C++ programming, most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class Tmyclass {           public:       std::string str; };   then we can create our objects with this Type of myclass as below, What is a copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), it must have a public copy assignment operator. Here is a simple syntax for the forced (defaulted) copy assignment operator with default option; Syntax (Since C++11),   class_name & class_name :: operator= ( const class_name& ) = default;   here is an example in a class:   Tmyclass& operator=( const Tmyclass& other) = default; // Copy Assignment Operator   What is a forced (default) copy assignment operator in C++? The forced copy assignment operator forces a copy assignment operator to be generated by the compiler and it is default in any class declarations. This means you don’t need to declare it as above, let’s give examples without using it. Let’s give a simple C++ example to copy assignment operator with default option, here is a simple class   class Tmyclass {   public:   std::string str;   };   This is same as below.   class Tmyclass {   public:   std::string str;     Tmyclass& operator=( const Tmyclass& other) = default; // Forced (Default) Copy Assignment Operator   };   As you see both are same, because this is default in any class declaration and it is automatically declared. And here is how you can use this “=” copy assignment operator on the objects of one of these given class examples,   Tmyclass o1, o2;   o2 = o1; // Using Copy Assingment Operator   Is there a full example to forced (default) copy assignment operator in C++? An example with a copy assignment operator in a class. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28   #include #include   class Tmyclass {   public:   std::string str;     // Tmyclass& operator=( const Tmyclass& other) = default; // Forced (Default) Copy Assignment Operator   };   int main() { Tmyclass o1, o2;   o1.str = “LearnCplusplus.org”;   o2 = o1; // Using Copy Assingment Operator   std::cout

Read More

What is Avoiding Implicit Copy Assignment In C++?

Object-Oriented Programming (OOP) is a method of mapping real-world objects and data to computer functions and data structures. Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. In Modern C++, one of the features of OOP is copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain what we mean by “avoiding implicit copy assignment operator”, and how can we use the delete option with copy assignment in C++ examples. What are classes and objects in C++? Classes are defined in C++ using the keyword class followed by the name of the class. Classes are the blueprint for the objects and they are user-defined data types that we can use in our program. Objects are an instantiation of a class, In C++ programming, because it is designed to be strongly object oriented most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class Tmyclass {           public:       std::string str; };   Then we can create our objects with this Type of myclass as below. What is copy assignment operator with delete option in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. Normally, a copy assignment operator is assigned in any class deceleration as default. For example, we can copy two object properties as below;   class Tmyclass {           public:       std::string str; };   Tmyclass o1, o2;   o1.str = “LearnCPlusPlus.org”;   o2 = o1;   When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), sometime you don’t want it to be copied with other external code lines. In this situation, you need to use copy assignment operator with delete option. Here is a simple syntax for the copy assignment operator with delete option; Syntax (Since C++11),   class_name & class_name :: operator= ( const class_name& ) = delete;   Here is an example in a class:   Tmyclass& operator=( const Tmyclass& other) = delete; // Deleting Copy Assignment Operator   What is avoiding implicit copy assignment in C++? In C++, the Copy Assignment operator is default in any class declaration and it is automatically declared. This is also called as the forced copy assignment operator which is default in any class declarations. This means, if you don’t want this default feature, you should delete by using delete option as given syntax above. Let’s give a simple C++ example of the copy assignment operator with default option, here is a simple class:   class Tmyclass {   public:   std::string str; };   In modern C++, this simple class has hidden copy assignment operator as default that is created automatically, this class example is same as below:   class Tmyclass {   public:   std::string str;     Tmyclass& operator=( const Tmyclass& other) = default; // Copy Assignment Operator   };   As you see both are same, and if you want to delete this copy operator to avoid implicit copy assignment usage, you need to use delete option as below.   class Tmyclass {   public:   std::string str;     Tmyclass& operator=( const Tmyclass& other) = delete; // Deleted Copy Assignment Operator   };   And here […]

Read More

What Is A Copy Assignment Operator in C++?

Object-Oriented Programming (OOP) is a method of mapping real-world objects and data to computer functions and data structures. Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. One of the features of an OOP Editor is a copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain what a copy assignment operator is along with some C++ examples. What are classes and objects in C++? Classes are defined in C++ using the keyword class followed by the name of the class. Classes are the blueprint for the objects and they are user-defined data types that we can use in our program. Objects are an instantiation of a class, In C++ programming, because it is designed to be strongly object oriented most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class myclass {           public:       std::string str; };   What is a copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), it must have a public copy assignment operator. Here is a simple syntax for the typical declaration of a copy assignment operator which is defaulted, Syntax (Since C++11).   class_name & class_name :: operator= ( const class_name& ) = default;   Here is an example in a class.   Tmyclass& operator=(const Tmyclass& other) = default; // Copy Assignment Operator   Is there a simple example of using the copy assignment operator in C++? The forced copy assignment operator is default in any class declarations. This means you don’t need to declare it as above, let’s give examples without using it. Let’s give a simple C++ example to copy assignment operator with default option, here is a simple class.   class myclass {   public:   std::string str;   };   Because this is default in any class declaration, and it is automatically declared. This class is same as below.   class myclass {   public:   std::string str;     Tmyclass& operator=(const Tmyclass& other) = default; // Copy Assignment Operator };   And here is how you can use this “=” copy assignment operator with both class examples above.   Tmyclass o1, o2;   o2 = o1; // Copy Assingment Operator   Is there a full example of how to use the copy assignment operator in C++? An example with a copy assignment operator in a Class. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27   #include #include   class Tmyclass {   public:   std::string str;        // Tmyclass& operator=(const Tmyclass& other) = default; // Copy Assignment Operator };   int main() { Tmyclass o1, o2;   o1.str = “LearnCplusplus.org”;   o2 = o1; // Using Copy Assingment Operator   std::cout

Read More

Typical Declaration Of A Copy Assignment Operator With std::swap

Object-Oriented Programming (OOP) is a method of mapping real-world objects and data to computer functions and data structures. Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. One of the features of an OOP tool is the copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain the typical declaration of a copy assignment operator with C++ examples. What are classes and objects in C++? Classes are defined in C++ using the keyword class followed by the name of the class. Classes are the blueprint for the objects and they are user-defined data types that we can use in our program. Objects are an instantiation of a class, In C++ programming, because it is designed to be strongly object oriented most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class myclass {           public:       std::string str; };   What is a copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), it must have a public copy assignment operator. Here is a simple syntax for the typical declaration of a copy assignment operator when the swap is used. Syntax:   class_name & class_name :: operator= ( class_name )   Here is an example in a class.   class Tmyclass {   public:   Tmyclass& operator=(Tmyclass other) // Using Copy Assingment Operator   {    // Copy or swap things    return *this;   } };   What is a typical declaration of a copy assignment operator with std::swap? Let’s give a simple C++ example of a typical declaration of a copy assignment operator with std::swap.   class myclass {   public:   std::string str;     myclass& operator=(myclass other)   {        std::cout

Read More

Typical Declaration Of A Copy Assignment Operator Without std::swap

Object-Oriented Programming (OOP) is a method of mapping real-world objects and data to computer functions and data structures. Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. One of the features of an OOP IDE is the copy assignment operator that is used with “operator=” to create a new object from an existing one. In this post, we explain what the typical declaration of copy assignment operator is along with some C++ examples. What are classes and objects in C++? Classes are defined in C++ using the keyword class followed by the name of the class. Classes are the blueprint for the objects and they are user-defined data types that we can use in our program. Objects are an instantiation of a class, In C++ programming, because it is designed to be strongly object oriented most of the commands are associated with classes and objects, along with their attributes and methods. Here is a simple class example below.   class myclass {           public:       std::string str; };   What is copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the “operator=“. When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), it must have a public copy assignment operator. Here is a simple syntax for the typical declaration of a copy assignment operator when the copy and swap idiom is not used, Syntax.   class_name & class_name :: operator= ( const class_name& )   Here is an example in a class.   Tmyclass& operator=( const Tmyclass& other) // Using Copy Assingment Operator { if (this != &other) // not a self-assignment { // Copy or swap things }    return *this; }   What is typical declaration of a copy assignment operator without std::swap? Let’s give a simple C++ example of the typical declaration of a copy assignment operator with std::swap. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17   class Tmyclass {   public:   std::string str;     Tmyclass& operator=( const Tmyclass& other) // Using Copy Assingment Operator   { if (this != &other) // not a self-assignment { std::cout

Read More

What Is The Rule of Zero in C++?

Object Oriented Programming (OOP) is a way to integrate with objects which can contain data in the form (attributes or properties of objects), and code blocks in the form of procedures (methods, functions of objects). These attributes and methods are variables and functions that belong to the class – part of the class’s code and they are generally referred to as class members. Classes and structs are very useful in modern programming. There are some rules to support the principles of programming, one of which is the Rule of Zero in C++. In this post, we explain what is Rule of Zero in C++ with examples. What is resource acquisition in C++? The principle of Resource Acquisition Is Initialization (RAII) term used in several OOP programming languages, which relates to the ability to manage resources, such as memory, through the copy and move constructors, destruction, and assignment operators. RAII is about the declaration and use of destructors, copy-move operators, and memory management in these members and methods. These cause new rules in development. What is the Single Responsibility Principle in C++? The Single Responsibility Principle (SRP) is a computer programming principle that states “A module should be responsible to one, and only one, actor.” This principle exposes a rule for the classes in C++, called Rule of Zero. Now, let’s see what the Rule of Zero in C++ is. What is the Rule of Zero in C++? Rule of Zero means that, if all members have default member functions, no further work is needed. This is the simplest and cleanest semantics of programming. The compiler provides default implementations for all of the default member functions if there are no special member functions that are user-defined. In other words, you should prefer the case where no special member functions need to be defined. In this rule, classes that have custom destructors, copy/move constructors, or copy/move assignment operators should deal exclusively with ownership; other classes should not have custom destructors, copy/move constructors or copy/move assignment operators. Rule of Zero helps simplify our C++ code without risking resource management issues at run time. The term The Rule of Zero was coined by R. Martinho Fernandes in his paper in 2012. This paper is highly recommended reading to get the full details of this concept. The Rule of Zero rule can be seen in the C++ Core Guidelines here C.20: If you can avoid defining default operations, do. As in the example below, std::map and std::string have all the special functions, so you don’t need to create a constructor and destructor for them.   class Tmy_map {     public:       // … no default operations       private:       std::string title;       std::map<int, int> coords; };   Tmy_map m;       // default construct Tmy_map m2 {m};  // copy construct   How can we apply the Rule of Zero in C++? Here are some notes as to-dos in Rule of Zero. A simple empty C++ class is perfectly equivalent to default implementations (Rule of Five) in a class. A modern compiler is able to provide a default implementation, in example, this simple class. This class is exactly the same as the one below in modern C++.   class Tx { public:    Tx() = default;       Tx(Tx const& other) = default;    Tx& operator=(Tx const& other) = default;       Tx(Tx&& other) = default;    Tx& operator=(Tx&& other) = default;       ~Tx() = default; }   Use a std::unique_ptr if your class can be moved but should not […]

Read More

How To Use Gamepad Or Joystick Controller In A C++ Builder FMX App?

C++ is one of the most powerful programming languages that we can use to create games that are playable with mouse, keyboard and gamepads or joysticks. We also use C++ in commerce, industry, in robotics, and in the control of IoT devices. Despite competition from other programming languages the games market is still very much dominated by C++. Many games seek to go beyond keyboards to control the gameplay by using specialized controllers either in addition to or instead of keypresses on the computer’s keys. Two of the most well-known controllers in these areas are joysticks or gamepads. The simplest examples of interfacing with game controllers on Windows is by using the XInput library. Even though XInput has been around for a long time it can still be used with the latest C++ Editor and compiler for Windows. In this post, we explain how you can use gamepad or joystick controller in C++ using with Xinput library. Is there a component for using a gamepad or joystick in C++ on Windows? If you are looking for a component library, there are Delphi and C++ Builder-compatible components built on the XInput library. The Controller library is a Delphi and C++ Builder component that allows applications to receive input from the Xbox Controller. The main features of this library are: Uses Windows XInput API Available for Delphi and C++ Builder from versions 6 right up to the current modern version 11. Source code included in the registered version. Royalty-free distribution. You can download the trial version of the XInput library, or you can buy a professional edition from here. How can I control a gamepad or joystick in C++ with Xinput Library? XInput library is deprecated but is still a supported library by Microsoft. They recommend moving towards the GameInput library or Windows.Game.Input for Windows applications. If we look at these kinds of libraries (i.e GamePad.h library), like MS’ own DirectXTK, we can see that the toolkit allows one to define USING_XINPUT vs. USING_GAMEINPUT vs. USING_WINDOWS_GAMING_INPUT to pick which underlying library is used. If we compare  XInput compared to GameInput: XInput library is old and easy to implement Windows applications. XInput library is limited to 4 controllers XInput library has no uniform interface to other input (like mouse/keyboard) XInput library occurs with higher latency XInput library is not friendly with other controllers. i.e. no support for Xbox One Rumble Motors. Briefly, DirectInput is better than XInput. If you still want to use XInput, you can check more about https://learn.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput XINPUT_GAMEPAD structure (declared in ) is explained here : https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad As in there, this structure has these members: wButtons, bLeftTrigger, bRightTrigger, sThumbLX, sThumbLY, sThumbRX, sThumbRY. Here wButtons member is used as a bitmask of the device digital buttons, it can be used as below, wButtons Device digital button flags Gamepad Bitmask XINPUT_GAMEPAD_DPAD_UP 0x0001 XINPUT_GAMEPAD_DPAD_DOWN 0x0002 XINPUT_GAMEPAD_DPAD_LEFT 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 XINPUT_GAMEPAD_START 0x0010 XINPUT_GAMEPAD_BACK 0x0020 XINPUT_GAMEPAD_LEFT_THUMB 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 XINPUT_GAMEPAD_A 0x1000 XINPUT_GAMEPAD_B 0x2000 XINPUT_GAMEPAD_X 0x4000 XINPUT_GAMEPAD_Y 0x8000 How to use a gamepad or joystick in a C++ Builder FMX application? Here are the steps to use gamepad or joystick in C++ Builder FMX app, Create a new Multi-Device C++ Builder FMX application Drag a Timer (TTimer) component on to Form In Object Inspector window, set its interval to 15 and be sure it is enabled Drag a shape Circle (TCircle) component on to Form In Object […]

Read More

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++, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 void SetBackgroundColor(TStyledControl *control, TAlphaColor color) {   control->NeedStyleLookup();   control->ApplyStyleLookup();   TFmxObject *fmxobj = control->FindStyleResource(“background”);   TRectangle *rect = new TRectangle(fmxobj);   fmxobj->AddObject(rect);   rect->Align = TAlignLayout::Client;   rect->Fill->Color = color;   rect->Stroke->Color = claNull;   rect->HitTest = false;   rect->SendToBack(); } 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. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #include #pragma hdrstop #include “Component_Background_Color_Unit1.h” //————————————————————————— #pragma package(smart_init) #pragma resource “*.fmx” TForm1 […]

Read More