If you are a beginner “Hello World” examples are good to understand feature of that programming language. It is good to understand how to edit text, how to write in its format, how to compile and link, how to debug and execute, how to deploy or release.
This example below is a modern “Hello World” example on Windows which runs with C++ Builder. Modern applications has GUI and they should be compatible with other operating systems (Windows, MacOS, iOS, Android). In C++ Builder FireMonkey projects are Multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android .
“Hello World” 3D example in C++ with ViewPort3D
ViewPort3D component is good to display 3D images, easy to rotate, move or animate
– Open C++ Builder or RAD Studio IDE
– Create a new MultiDevice Application in C++ Builder from File menu
– Save all units and project files with “HelloWorld_” prefix in a HelloWorld folder.
– Add ViewPort3D by dragging on to Form and a Text3D inside this ViewPort3D.
– Go to Properties of Text3D from the left side Object Inspector and find set Width 20, set WordWrap unchecked and find Text property, change it to “Hello World”
– Add a Button at the bottom of ViewPort3D
– Double click to Button to create OnClick event, inside that Button1Click event write lines as below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <fmx.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.fmx" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { UnicodeString hi; hi.printf(L"Hello :)"); Text3D1->Text=hi; } |
– Run project by hitting F9 or click to Run with Debugging
– If there is error, please check your lines
– If all is fine then save all project
– if you check your header file you will see all your objects (Memo, Button etc. ) are automatically defined as below. You don’t need to change anything here
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 |
#ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <FMX.Controls.hpp> #include <FMX.Forms.hpp> #include <FMX.Controls.Presentation.hpp> #include <FMX.Controls3D.hpp> #include <FMX.Objects3D.hpp> #include <FMX.StdCtrls.hpp> #include <FMX.Types.hpp> #include <FMX.Viewport3D.hpp> #include <System.Math.Vectors.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TViewport3D *Viewport3D1; TText3D *Text3D1; TButton *Button1; void __fastcall Button1Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif----------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif |