C++Introduction to C++Language FeatureLearn C++

How To Make A New 64bits FMX Component

How To Make A New 64bits FMX Component

How can I create a new 64bits FMX Component for my C++ app? How can I use the New Component menu? How can I use and fill the New Component Wizard for 64bits FMX applications? What is a Component in C++? What is an Object in C++? Let’s answer these questions.

One of the most powerful features of the C++ Builder is its own library of great components that can be used with or without visuals. Components make programming easy, you can do many operations easily without knowing low coding or some specific features needed. Every component that you drag into is an object of that component class. For example TEdit is a Class Type, a Component and Edit1 is an Object from the TEdit Component.

One word of caution – RAD Studio runs in 32bits and this means all design-time components must be 32bits. You can compile 64bits VCL components but you can NOT install a 64bits VCL Component into 32bits RAD Studio. On the other hand, you can create 32bits VCL component that runs with with your 64bbits applications. That means while the RAD Studio IDE is 32bits you can create 64bits applications with your 64bits components. Now let’s see how we can do this.

What is a component in C++ ?

In C++ Builder and Delphi, every object (i.e. Edit1) inherits from TObject class (for example TEdit1). Objects that can appear in the Form Designer inherit from TPersistent or TComponent Controls, which appear to the user at run time, and inherit from TControl. There are two types of controls: graphic controls, which inherit from TGraphicControl, and windowed controls, which inherit from TWinControl.

A visual control like TCheckBox inherits all the functionality of TObjectTPersistentTComponentTControl, and TWinControl, and adds specialized capabilities of its own.

A Component in C++ Builder and Delph specifies the base class for all components. Components can be added to the Tool palette and manipulated at design time. Components can own other components.

What does TComponent do?

The TComponent branch contains classes that descend from TComponent but noTControl. Objects in this branch are components that you can manipulate on forms at design time but which do not appear to the user at run time. They are persistent objects that can do the following:

  • Appear on the Tool palette and be changed on the form.
  • Own and manage other components.
  • Load and save themselves and their state and prosperities.

Several methods introduced by TComponent dictate how components act during design time and what information gets saved with the component. Streaming (the saving and loading of form files, which store information about the property values of objects on a form) is introduced in this branch. Properties are persistent if they are published and published properties are automatically streamed.

Why is TComponent important for descendant components?

The TComponent branch also introduces the concept of ownership, which is propagated throughout the component library. Two properties support ownership: Owner and Components. Every component has an Owner property that references another component as its owner. A component may own other components. In this case, all owned components are referenced in Components property of the component.

The constructor for every component takes a parameter that specifies the owner of the new component. If the passed-in owner exists, the new component is added to Components list of that owner. Aside from using the Components list to reference owned components, this property also provides for the automatic destruction of owned components. As long as the component has an owner, it will be destroyed when the owner is destroyed. For example, since TForm is a descendant of TComponent, all components owned by a form are destroyed and their memory freed when the form is destroyed. (Assuming, of course, that the components have properly designed destructors that clean them up correctly.)

If a property type is a TComponent or a descendant, the streaming system creates an instance of that type when reading it in. If a property type is TPersistent but not TComponent, the streaming system uses the existing instance available through the property and reads values for the properties of that instance.

Components that do not need a visual interface can be derived directly from TComponent. To make a tool such as a TTimer device, you can derive from TComponent. This type of component resides on the Tool Palette but performs internal functions that are accessed through code rather than appearing in the user interface at run time.

Components, Packages and Libraries for 64bits Applications

64bits Windows Components, Packages, and Libraries Require 32-bit Design-Time Versions

If you are creating 64-bit Windows components, packages, or libraries, you need to have 32-bit Windows design-time versions of these if you want to use these components, packages, and libraries in the IDE during application development. This requirement exists because the IDE is a 32-bit Windows program.

For example, if you are using the New Component wizard, you need to start by creating a 32-bit Windows version of your component. Later you compile your component again, as a Win64 component, by setting the Target Platform to be 64-bit Windows (in the Projects Window). RAD Studio saves output files (such as .bpl and .dcp) in platform-specific directories located inside your project output directory.

If you want to learn more about 64bits application development please read 64-bit Windows Application Development DockWiki

How do I use the “New Component” wizard?

We can use New Component wizard to create a new component for Delphi or C++Builder. The personality of your current project is detected and used for the component.

  1. Create a folder for your component (i.e. on the Desktop create a “MyFMXComponent” folder)
  2. Select New Component… from Component menu of RAD Studio or C++ Builder as below
How To Make A New 64bits FMX Component Involking the new component wizard

3. The “New Component” Wizard will help you to create your component. To create a new FMX component choose “FireMonkey for C++”

How To Make A New 64bits FMX Component Choosing FireMonkey

then click the “Next>>” button.

4. Now we can choose an ancestor component. In this list, you will see that you can choose all official pre-installed components and any additional installed or third-party components as an ancestor.

How To Make A New 64bits FMX Component Selecting an ancestor component

For a general control component you can choose TControl. For example if your want to create your own Edit (TEdit) box including its features you can choose TEdit. For a custom Button (TButton) you can choose “Button” and so on.

In our example, we will make a custom animating Image component. So let’s search TImage from the search. Select TImage and then Press “Next>>” button.

How To Make A New 64bits FMX Component Choosing the TImage

5. In this step we should add a Class Name to our component. This Class Name should, by convention, start with a “T”. T represents the Class Type. Let’s name our component as TMyFMXComponent. We can choose a category from the Palette Name or we can add a new Category. Let’s add a new category MyNewCategory. We should add A Unit name, Unit file name should be different from the Class Name and it should be full path in our component folder. In our example Unit Name can be “C:\Users\<UserName>\Desktop\MyFMXComponent\MyFMXCompo1.cpp“. Wizard should be like this in accordance with your user name:

How To Make A New 64bits FMX Component Filling out the new component's properties.

So In our example we used:

Class Name : TMyFMXComponent
Palette Name: MyNewCategory
Unit Name: <Folder Path\>”MyFMXCompo1.cpp” for example here “C:\Users\ata\Desktop\MyFMXComponent\MyFMXCompo1.cpp

and then Press “Next>>” button.

6. We will create a new package so, select Install to New Package and then Press “Next>>” button.

How To Make A New 64bits FMX Component Choosing where to install the newly created component

7. Now we should add Full Package Name. Do not enter just a name here. Be sure that this full path is shown, otherwise your project can be created in default project folder. Our project file should be in our MyFMXComponent folder, thus press “…” and select our MyFMXComponent folder. Note that package name shouldn’t be as same as Class name. In out example let’s define our project as “MyFMXCompo2021“, so the project full path in our example will be something like “C:\Users\ata\Desktop\MyFMXComponent\MyFMXCompo2021.cbproj“. Consider that your user name is different so you must modify this in accordance with your user name or folder path.

How To Make A New 64bits FMX Component Choosing a name for the new component package

8. Select Finish Button.

9. Now it will ask where to save “MyFMXCompo1.cpp” file select our MyFMXComponent folder and keep file name same, and press Save button.

How To Make A New 64bits FMX Component Saving for the first time

If you see a confirmation as below select Yes.

How To Make A New 64bits FMX Component No framework assigned you did a bad

10. Now it should compile your first VCL component. When done you should see this message below.

How To Make A New 64bits FMX Component Problem rectified

11. After pressing OK you may see it is asking where to save its PCH file, select the same MyFMXComponent folder as in example below

How To Make A New 64bits FMX Component Saving things to the right places

12. Now you can Install your components by selecting “Install” from the right click menu over the “MyFMXCompo2021.bpl” file in your Project Group

How To Make A New 64bits FMX Component The Component code in the IDE

You can also Uninstall your component from this right click menu menu as well. If you have any problems or for any new changes please check the Using the New Component Wizard DocWiki

How do we test our new FMX component?

  1. Create a new Multi-Device C++ Builder FMX Project
  2. On form design mode, in your palette you will se MyNewCategory you will see TMyFMXComponent. You can drag your new custom component to you form.
How To Make A New 64bits FMX Component The component palette

3. Now you can compile your project with your new component by pressing Run or F9 . Note that you need your MyFMXCompo1.h so if your project asks select the header file location or add it to a include path. You can select as below and press OK button.

How To Make A New 64bits FMX Component The can't find header" error message.

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 versions of C++ Builder and there is a trial version you can download from here.

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.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

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++?