C++C++11C++14C++17ComponentsIntroduction to C++Language FeatureLearn C++

Five Simple Examples Of C++ FMX Applications

The C++ Builder CE Community Edition is a free version of professional C++ Builder that you can develop GUI based desktop and mobile applications in C++. In this post, we will give you five simple C++ FMX applications as examples that you can compile with C++ Builder 11 CE.

Five Simple Examples Of C++ FMXApplications the C++ CE Splash screen

The latest C++ Builder 11 CE was released in April 2023. If you are a start-up developer, student, hobbyist or just interested in learning to code then C++ Builder Community Edition may well be just the thing for you. Read the FAQ notes on the CE license and then simply fill out the form and download C++ Builder 11 CE.

If you download C++ Builder Community Edition (or RAD Studio CE version) or any Professional, Architect, Enterprise versions of C++ Builder. Install it on your windows computer and run RAD Studio or C++ Builder. Beginners and students normally start to learn C++ with simple code. Let’s create a new Multi-Device C++ application for Windows by using FMX framework in C++ Builder CE.

How to develop C++ FMX applications in C++Builder CE?

If you download and install the C++ Builder CE Community Edition then we can start to coding,

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. VCL applications focus only Windows, if you want to develop same app for multiple-OS’es you can use FMX. FMX and VCL mostly has similar components and component properties and methods, there are some small changes in different components. There are also significant changes in graphics to support multi-OS devices. Personally, I found that FMX has more options in graphics and much more powerful than VCL in graphical operations. Let’s start to develop a C++ app with GUI using FMX framework.

1. Choose File->New-> “Multi-Device Application – C++ Builder” menu.

Five Simple Examples Of C++ FMX Applications Creating a new multi device application

This will create a New C++ Project for Windows. This will allow you develop C++ apps with FMX UI elements. If you don’t need UI Elements, this means you don’t need VCL or FMX frameworks, you create a console application too. Modern applications have a GUI’s and skinned Styles. Note that VCL projects are Windows only and FireMonkey projects are Multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android.

2. Save all Unit files and Project file to a folder.

3. Drag components to your form design

Simply drag and drop components from the Palette window on the right side; Memo (TMemo) and Button (TButton) to your form design. Arrange their width, height and position. You can edit each of their properties from the Object Inspector on the left side.

Five Simple Examples Of C++ FMX Applications dropping a TMemo on the form

Note that you can switch between the GUI Design mode to Code Mode by pressing F12, or vice versa. If you want, you can switch to your header file (.h) of your cpp file (.cpp) from the button tabs. You can change your Build Configuration from the left Project window by setting it to Debug or Release mode.

4. Double click to Button1 to create OnClick() event for this button. Add these lines into Button1Click() event, between { and } brackets as given below,

This example above is a modern “Hello World” example for Windows which runs with C++ Builder.

5. Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application. You should see this below as a form application

If you get an error, check your code – it’s easy to mistype or have the braces (“}” characters) in the wrong place. Note that C++ is case sensitive, so upper and lower characters should be also same. Then press the F9 key or just click the Run button again.

You can change the font property of Memo, here we used Consolas 9 font that has fixed width.
From this point, you can add more codes or you can switch back to design mode by pressing F12. And you can add more components, then more code. This is how modern C++ coding works with an UI Toolkit.

How to do calculations in C++ FMX applications?

As in same example above, now lets do another simple calculation. We have a price of a product and there is VAT percentage, then we want to calculate total price of this product. To do this, we should set price and VAT, then we can calculate VATprice and at the final we need to print price and VATprice as a total to the Memo as below,

Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together.

How to enhance C++ FMX applications with C++Builder CE?

As in the same example above, now lets do a simple calculation. We have a price of a product and there is VAT percentage, then we want to calculate total price of this product. To do this, we should set price and VAT, and we need to calculate VATprice and totalprice too. So we can define these variables below,

We can define a UnicodeString to set formated texts, then we can print this. UnicodeString has a printf function in modern C++ as in classic C function. Thus, we can print inputs and calculate totalprice as below,

Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application. You should see this below as a form application.

Five Simple Examples Of C++ FMX Applications screen 1

How to get input in C++ FMX applications?

Lets continue to same example. Let’s add more components to get inputs from user. Todo this, drag 2 Labels (TLabel) and 2 Edits (TEdit) components, and we will have a Memo (TMemo) and a Button (TButton) as below,

Five Simple Examples Of C++ FMX Applications screen 2

Double click to Button1, first we need to define our variables. Then we can get the price and VAT values from the Text of Edit1 and Edit2. We should convert Text to float values by using StrToFloat() function as below,

and other calculations and printing will be same as examples above. Thus, all Button1Click() event will be as below,

Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application. This time our application is able to calculate different values. In example, you can see this below as a form application.

Five Simple Examples Of C++ FMX Applications screen 5

Example 5. How to use loops in C++Builder CE FMX application?

We can create another example to calculate the price of many different product counts. Here is how you can use for() loop,

Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application. This time our application is able to calculate different values of counts in a loop. You should see this below as a form application.

Five Simple Examples Of C++ FMX Applications screen 6

Note that, If you want to see results faster, you can use Memo1->Lines->BeginUpdate(); before the for() loop, and Memo1->Lines->EndUpdate(); after the for() { } loop;

Five Simple Examples Of C++ FMX Applications 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.


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++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?

C++C++17C++20Introduction to C++Language FeatureLearn C++Syntax

Learn How To Use Clamp (std::clamp) In Modern C++ 17 and Beyond