C++ Builder

Using Python4Delphi with C++Builder (webinar)

David I. has a fantastic blog post on using Python4Delphi with C++Builder. This was inspired by our previous webinars on the topic. and is the result of his collaboration with Kiriakos (AKA PyScripter), the maintainer of Python4Delphi, who also made some changes in the library to work better with C++Builder. By popular request, David and Kiriakos have also agreed to run a Python for C++ developers webinar where you can learn to leverage Python from your favorite C++ developer tools. Date: Wed, Dec 2nd, 2020 Time: 9 AM CST/1500 UTC  

Read More

Apple Platforms Patch for RAD Studio 10.4.1

We have just released a new patch focused on improving RAD Studio 10.4.1 support for XCode 12, iOS 14 and macOS 11 Big Sur (Intel): these are operating systems and tools which were not available when 10.4.1 shipped. Specifically, the patch offers fixes for a Delphi exception issue on macOS 11 Big Sur Intel (which was also affecting PAServer when running on that platform, meaning this patch includes a new version of PAServer), SDK import from Xcode 12, and debugging applications on an iOS 14 device. Notice that new ARM-based Macs running macOS 11 Big Sur can execute macOS apps built for the Intel platform, including those built with Delphi 10.4.1, via the Apple Rosetta 2 compatibility layer. The patch can be installed via GetIt (with automatic installation via a deferred package, applied as you restart RAD Studio) or a direct download from my.embarcadero.com (available shortly) and manual installation. In both cases you’ll have to copy the PAServer for macOS installer to your Mac and install it manually. The readme file includes additional information and details.

Read More

Beautiful Responsive Home Screen UI Templates For FireMonkey Available For Free Via GetIt In The IDE

New FireMonkey developers tend to make unresponsive and bad user experience. For this, we should show guidelines and sample projects to learn how to create stunning FireMonkey projects.  This FireMonkey UI template includes three different designs for implementing an app home screen in a multi-device application.  You can get these sample UI templates from GetIt easily!  What can you learn from these samples? Use cases of TFrame Tab Controls Blur backgrounds Menu and Navigation  Simple & grid layouts and many more Be sure to check out these samples to learn more about FireMonkey app designing guidelines and FireMonkey multi-device responsive application designing! Be sure to check out other resources on building FireMonkey applications:

Read More

Ultimate Compression Toolkit For Delphi And C++ Builder Developers

procedure TAbZipperTests.CreateAndTestBasicZipFile; var   ExtractDir, TestFileName : string;   AbUnZip : TAbUnZipper; begin   // Test with Setting BaseDirectory and not specifying AutoSave   TestFileName := TestTempDir + ‘basic.zip’;   if FileExists(TestFileName) then     DeleteFile(TestFileName);   Component.FileName := TestFileName;   Component.BaseDirectory := TestFileDir;   Component.AddFiles(‘*.*’,faAnyFile);   Component.Save;   Component.FileName := ”;   CheckFileExists(TestFileName);     AbUnZip := TAbUnZipper.Create(nil);   try     AbUnZip.FileName := TestFileName;     // Clean out old Directory and create a new one.     Extractdir := TestTempDir + ‘extracttest’;     if DirectoryExists(ExtractDir) then       DelTree(ExtractDir);     CreateDir(ExtractDir);     // Extract Files.     AbUnZip.BaseDirectory := ExtractDir;     AbUnZip.ExtractFiles(‘*.*’);     // Compare Extracted Files     CheckDirMatch(TestFileDir,ExtractDir);   finally     AbUnZip.Free;   end;   DeleteFile(TestFileName); end;

Read More

Learn To Use Events To Build Python GUI Apps For Windows With Delphi And C++

An event links an occurrence in the system with the code that responds to that occurrence. The occurrence triggers the execution of a procedure called an event handler. The event handler performs the tasks that are required in response to the occurrence. Events allow the behavior of a component to be customized at design-time or at run time. Do you want to trigger and handle an event similar to Delphi events? Python4Delphi provides a mechanism to do that. This post will guide you on how to create events using Python4Delphi Components. Python4Delphi Demo21 Sample App shows how to create a Module, Python type, and add an event to it and define the event, Import the module and Python Type in a python script, and access the created event. You can find the Demo21 source on GitHub. Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi. Components used in Python4Delphi Demo21 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. TPythonGUIInputOutput: Inherited from TPythonInputOutput (which works as a console for python outputs) Using this component Output property you can associate the Memo component to show the Output. TPythonModule: It’s inherited from TMethodsContainer class allows creating modules by providing a name. You can create events using the Events property. After creating the event with a name, its handler can be defined by clicking the OnExecute method which takes the sender, PythonObject, and a variable parameter result as argument. TPythonType: It’s inherited from TGetSetContainer class contains a set of APIs to create, manage a Python Type in Delphi. Similar to TPythonModule, this also has Events property. TPyPoint Delphi class implementing a new Python type. It must derive from TPyObject or one of its descendants. Then it must override some methods, like the constructors, the RegisterMethods, and the type services’ virtual methods. TMemo: A multiline text editing control, providing text scrolling. The text in the memo control can be edited as a whole or line by line. You can find the Python4Delphi Demo21 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo21.dproj. Open this project in RAD Studio 10.4.1 and run the application. Implementation Details: PythonEngine1 provides the connection to Python or rather the Python API. This project uses Python3.9 which can be seen in TPythonEngine DllName property. PythonGUIInputOutput1 provides a conduit for routing input and output between the Graphical User Interface (GUI) and the currentlyexecuting Python script. PythonModule1 with Module name spam is created. Created an eventPythonModule1.Events[0]. And on execute event(PythonModule1Events0Execute) defined with below code. procedure TForm1.PythonModule1Events0Execute(Sender: TObject; PSelf, Args: PPyObject; var Result: PPyObject); begin with GetPythonEngine do begin Result := PyUnicodeFromString(‘Hello world !’); end; end; procedure TForm1.PythonModule1Events0Execute(Sender: TObject; PSelf,   Args: PPyObject; var Result: PPyObject); begin   with GetPythonEngine do   begin     Result := PyUnicodeFromString(‘Hello world !’);   end; end; PythonType1 during initialization, associate PyObjectClass with the created TPyPoint class. Created an event PythonType1.Events[0]. And on execute event(PythonType1Events0Execute) defined with below code. procedure TForm1.PythonType1Events0Execute(Sender: TObject; PSelf, Args: PPyObject; var Result: PPyObject); var dx, dy : Integer; Instance : TPyPoint; begin with GetPythonEngine do begin // Convert the PSelf Python object to a Delphi instance pointer. Instance := TPyPoint(PythonToDelphi(PSelf)); // first we extract the arguments if PyArg_ParseTuple( args, ‘ii:Point.Offset’,@dx, @dy ) 0 then begin // if it’s ok, then we call the method […]

Read More

Flexible Way To Set And Get Variant Array Between Delphi and Python For Building Windows Apps

rocedure TForm1.Button1Click(Sender: TObject);     procedure DisplayArrayVar( V : Variant );   var     i, j : Integer;     item : Variant;     s : String;   begin     Memo2.Lines.Add(‘Displaying a variant array generated from a Python sequence:’);     for i := VarArrayLowBound( V, 1 ) to VarArrayHighBound( V, 1 ) do       begin         item := V[i];         for j := VarArrayLowBound( item, 1 ) to VarArrayHighBound( item, 1 ) do           begin             s := item[j];             Memo2.Lines.Add(Format(‘(%d, %d) = %s’,[i, j, s]));           end;       end;   end;   var   ComArray : Variant; begin   ComArray := VarArrayCreate([0, 3, 0, 2], varVariant);   ComArray[0, 0] := 1;   ComArray[0, 1] := 1.1;   ComArray[0, 2] := ‘a’;   ComArray[1, 0] := 2;   ComArray[1, 1] := 2.2;   ComArray[1, 2] := ‘b’;   ComArray[2, 0] := 3;   ComArray[2, 1] := 3.3;   ComArray[2, 2] := ‘c’;   ComArray[3, 0] := 4;   ComArray[3, 1] := 4.4;   ComArray[3, 2] := ‘d’;   PythonModule1.SetVarFromVariant( ‘L’, ComArray );   PythonEngine1.ExecStrings(Memo1.Lines);   DisplayArrayVar( PythonModule1.GetVarAsVariant( ‘L’ ) ); end;

Read More

RAD Studio 10.4 Launch Webinar Replay And Feature Round Up For Building Powerful Native Cross-Platform Apps

RAD Studio is the ultimate IDE with features both C++ and Delphi developers love to design, code, debug and test for cross-platform platform with native performance. Supported Platforms: Windows, iOS, macOS, Linux, and Android (some platforms Delphi only) Major Delphi Code Insight Redesign: The largest and best improvement to Delphi’s code tooling in many years, RAD Studio 10.4 provides Code Insight using a Delphi implementation of the Language Server Protocol (LSP). LSP is a technique for calculating results for code completion, navigation, or similar in a separate process. This means that the IDE will never block while completing and Code Insight will provide accurate results. You can also use code completion while debugging. 10.4 provides a much enhanced developer productivity experience when working with large projects with millions of lines of code. Accurate Error Insight results (red squiggles) and errors shown in the structure view. Delphi – Custom Managed Records: A key language addition to the Delphi language, the Delphi record type now supports custom initialization, finalization, and copy operations. Developers now have the ability to customize how records get created, copied, and destroyed, by writing the code to be executed at the various steps. This adds additional power to records in Delphi, a construct used to achieve better efficiency compared to classes. Unified Memory Management for Delphi and C++: Delphi memory management is now unified across all supported platforms – mobile, desktop, and server – using the classic implementation of object memory management. Compared to Automatic Reference Counting (ARC), this offers better compatibility with existing code and simpler coding for components, libraries, and end-user applications. The ARC model remains for string management and interface type references for all platforms. For C++, this change means that the creation and deletion of Delphi-style classes in C++ follow normal memory management just like any heap-allocated C++ class, significantly reducing complexity. New C++ Builder Features: Expanded C++ libraries support : Ported numerous popular C++ libraries to C++Builder, providing optimized support for use within C++Builder. This includes libraries such as ZeroMQ, SDL2, SOCI, libSIMDpp, and Nematode, as well as others already supported such as Eigen, available for download through the GetIt Package Manager. Win 64-Debugging and Linker for C++ : A new debugger for Windows 64-bit for C++. Based on LLDB, this debugger introduces significant stability improvements when debugging 64-bit applications, as well as a key new feature assisting evaluating and inspecting types like C++ and Delphi strings plus STL collections. Toolchain performance and quality improvements: A large number of STL improvements from Dinkumware, Several key RTL methods, Several improvements to CMake support. VCL Styles for High DPI: The VCL Styles architecture has been extended to support High DPI and 4K monitors. All UI controls on the VCL form are now automatically scaled for the proper resolution of the monitor the form is displayed on. The style API has been fully revised to support high DPI styles. Updated a large number of our built-in and premium VCL styles to provide support for the new High-DPI style mode, letting you design visually stunning applications for any monitor. VCL Per Control Styling -VCL developers can now use multiple VCL styles in different forms within a single application or even different visual controls that are on the same form. This also enables you to use third-party unstyled […]

Read More

Learn How To Use C++ Variadic Templates For Windows Development With C++Builder

C++ Builder supports the Variadic templates. Variadic templates are template that take a variable number of arguments. Both the classes and functions can be variadic offered by C++11. Templates have been a powerful feature in C++. Now, after the introduction of variadic templates, templates have proven themselves even more powerful. Variadic templates are a trustworthy solution to implement delegates and tuples. Here’s a variadic class template: template class VariadicTemplate {}; templatetypename… Arguments> class VariadicTemplate {}; Any of the following ways to create an instance of this class template is valid: VariadicTemplate instance; VariadicTemplate instance; VariadicTemplate, std::string, std::string, std::vector> instance; VariadicTemplatedouble, float> instance; VariadicTemplatebool, unsigned short int, long> instance; VariadicTemplatechar, std::vectorint>, std::string, std::string, std::vectorlong long>> instance; Here’s a function template: template void SampleFunction(Arguments… parameters) {}; template void SampleFunction(Arguments… parameters) {}; The contents of the variadic template arguments are called parameter packs. These packs will then be unpacked inside the function parameters. For example, if you create a function call to the above variadic function template, SampleFunction(16, 24); SampleFunctionint, int>(16, 24); an equivalent function template would be like this: template void SampleFunction(T param1, U param2){}; templatetypename T, typename U> void SampleFunction(T param1, U param2){}; Head over and find out more about C++ variadic templates in the Embarcadero DocWiki!

Read More

Learn About C++11 In This Video Archive Conversation With C++ Designer Bjarne Stroustrup From 2014

In this session, you can see and listen to a conversation with C++ designer, Bjarne Stroustrup.  Overview ISO/IEC 14882-2011 aka C++11, formerly “C++0x” How C++ 11 builds on C++’s strengths How C++ 11 makes C++ easier to Application portability C++’s ubiquitous presence in the markets About Bjarne Stroustrup Designer and original implementor of C++ Distinguished Professor and holder of the College of Engineering Chair in Computer Science, Texas A&M Member, the C++ standards committee When is the right time to start a language standard? What’s like to work on the C++ standard with others from the industry and academia? Bjarne Stroustrup has shown his views on C++. And how the C++ designed, what things were the influence for the creation of the C++ language. What are some of the key areas that help make C++ easier to use? Is inheritance overused? Be sure to watch the whole session to get a deep understanding of C++ language!

Read More

Learn About How To Use Non-static Data Member Initializers For Windows Apps In C++

Embarcadero Bcc32c and bcc32x (Clang-enhanced compiler for Win32) implements all of the ISO C++11 standard. It includes the use of non-static data member to be initialized where it is declared. The basic idea for C++11 is to allow a non-static data member to be initialized where it is declared (in its class). A constructor can then use the initializer when run-time initialization is needed. #include struct B { B(int, double, double); }; class A { int a = 7; // OK std::string str1 = “member”; // OK B b = {1, 2, 3.0}; //OK std::string str2(“member”); // ill-formed }; #include   struct B {         B(int, double, double); };   class A {         int a = 7; // OK         std::string str1 = “member”; // OK         B b = {1, 2, 3.0}; //OK         std::string str2(“member”);   // ill-formed }; Why useful.-Easier to write.-You are sure that each member is properly initialized.-You cannot forget to initialize a member like when having a complicated constructor. Initialization and declaration are in one place – not separated.-Especially useful when we have several constructors.-Previously we would have to duplicate initialization code for members.-Now, you can do a default initialization and constructors will only do its specific jobs. If a member is initialized by both an in-class initializer and a constructor, only the constructor’s initialization is done (it “overrides” the default). Head over and find out more about C++ non-static data member initializers in the Embarcadero DocWiki!

Read More