Noutați

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

Impressive Procedural Game And 3D Engine Built In Delphi Is A Work Of Art

Developer Zudomon (Nick Pützer) has been building an impressive procedural game called StoneQuest and 3D engine in Delphi. He has put in over 12,000 hours since 2011 building the engine and game. The whole game and content is less than 15MB in size! One of the goals of the developer is for him to build it entirely himself in Delphi. The current gameplay is reminiscent of Minecraft. According to the developer “I use a lot of procedural content. All the models are created by code only. This mean, later I can do many different models from them! My engine is able to spread microgeometry over the world, real tiny 3d models. Every grass blade and clover plant is real and interact with players. Every cube face of the voxel world has it’s own texture. I only have a few procedural textures yet. They doesn’t repeat. There are dynamic volumetric 3d clouds. And volumetric fog in the valley, where sun rays shine through the trees. For me atmospheric and immersion is a very important thing.” The project is still in active development but you can download and play it in it’s current state. At this point it is a work of art which is beautiful to behold. Website https://stonequest.de/ Ready to get started with the latest RAD Studio version? Start Free Trial or Learn More About Upgrading Patreon https://www.patreon.com/Zudomon Screenshot Gallery Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

Read More

Easily Bridge Your FireMonkey Windows Apps And JavaScript Using ScriptGate

Before knowing how to bridge FireMonkey application and JavaScript using ScriptGate, Let’s understand what is Native App and Hybrid App? What’s the difference between them? How to develop a Hybrid App using Delphi? Is it possible? What’s the challenge? This post will guide you to understand better. Native Apps : A software application built in a programming language, for the specific platform like iOS, Android ,Windows, macOS and Linux. The pros and cons are, The Best performance – no extra calculations or interpretations layers. No way to update UI without updating the app (only if you don’t have some built-in UI update engine) Your app can be used only for target platforms. You cannot start the app inside the browser without using something like Thinfinity Virtual UI. Hybrid Apps: Hybrid apps are part native apps, part web apps. It can take advantage of some device features available. Like web apps, they rely on HTML being rendered in a browser, with the caveat that the browser is embedded within the app. The pros and cons are, Possibility to update the UI and logic without updating the whole app. Great opportunity if you like to use HTML/CSS/Javascript for UI and even for business logic. Not the best performance – your app UI or business logic ( like Javascript) executes inside the browser component. Risk during submission to app stores (but your app still looks like a native app to the play store). Hybrid apps with Delphi is that possible? Yes, using the TWebBrowser component and ScriptGate. Why do we want to use ScriptGate? It looks like a native application, access to platform-specific features, like get device token, working with push notifications (including background mode), access to BLE and other hardware onboard features, working with permissions, and so on. Possibility to publish the application to app stores like a native app. What’s the challenge here?The main challenge – organize communication between your HTML/CSS/JavaScript web application, stored inside the TWebBrowser component, and your Host application code..E.g) Get Push notifications token in the host app and transfer it to the web app. Initiate permission requests from web app before calling some restricted function, e.g perform calls. Register geofences for the platform, e.g get a list of geofences via Rest API from Web Server using javascript code and put them to the OS using host app. ScriptGate solves the above challenges: ScriptGate is a library that allows you to call back and forth between JavaScript and Delphi code on TWebBrowser across Android, iOS, macOS, and Windows. Watch the Video Demonstration on how to bridge the FMX and JavaScript using ScriptGate mentioned below. Check out the other ways to Bridge Your Delphi Application and Javascript here. You can download the ScriptGate library for Delphi over on BitBucket.

Read More

Feel The Lightning Speed Of The Delphi Compiler For Maximum Productivity!

In this demonstration, you can see the speed of Delphi compiler which compiles one million lines of code in 5 seconds! This is epic! This demonstration has done using Delphi 10.1 Berlin version. Since then, we have got big major updates, compiler enhancements, and Delphi language enhancements. Be sure to check out the latest update in this post: 1 Million Lines of Code: 18,000 pages of printed text 14 copies of War and Peace 25 copies of Ulysses 63 copies of Catcher in the Rye Check out this million lines of code visualization Improving Compile Times Library packages – Built-in, 3rd party, and shared libraries are precompiled so they don’t need compilation with each build Precompiled units – Only new compile the units that change since the last compile Divide large projects into multiple smaller packages Inlining compiler optimizations, run time packages, optional debugging, and RTTI Watch the demonstration and feel the speed!

Read More

Powerful Visual Optimizer For Investment Portfolios Built In Delphi

OptiFolio is an advanced interactive portfolio optimization software built in Delphi. According to the developer “OptiFolio can produce an interactive visualization of all possible investment strategies for any given set of financial assets. Delphi’s compiled code extreme execution speed makes it possible to examine millions of strategies per second. This global perspective of feasible portfolios helps investors around the world to identify their best long-term strategies.” Some of it’s portfolio optimization features include: Apply quasi-stochastic and stochastic optimization methods, Find global optimums even with numerous and complex constraints, Report the composition of each point along the efficient frontier, and Save optimum portfolios for further analysis. Additionally, it has performance statistics to Calculate expected return, standard deviation and Conditional Value-at-Risk and Use multivariate copulas to forecast the performance of any portfolio. Website https://www.optifolio.net/ Ready to get started with the latest RAD Studio version? Start Free Trial or Learn More About Upgrading Screenshot Gallery Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

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

Easily Pass Values Between Delphi And Python In Your Windows Delphi/C++ Builder Apps

function TForm1.GetProperty(pSelf, Args : PPyObject) : PPyObject; cdecl; var   key : PAnsiChar; begin   with GetPythonEngine do     if PyArg_ParseTuple( args, ‘s:GetProperty’,@key ) > 0 then       begin         if key = ‘Title’ then           Result := VariantAsPyObject(cbTitle.Text)         else if key = ‘Name’ then           Result := VariantAsPyObject(edName.Text)         else if key = ‘Informatician’ then           Result := VariantAsPyObject(cbInformatician.Checked)         else if key = ‘PythonUser’ then           Result := VariantAsPyObject(cbPythonUser.Checked)         else if key = ‘Age’ then           Result := VariantAsPyObject(edAge.Text)         else if key = ‘Sex’ then           Result := VariantAsPyObject(rgSex.ItemIndex)         else           begin             PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format(‘Unknown property “%s”‘, [key])));             Result := nil;           end;       end     else       Result := nil; end;   function TForm1.SetProperty(pSelf, Args : PPyObject) : PPyObject; cdecl; var   key : PAnsiChar;   value : PPyObject; begin   with GetPythonEngine do     if PyArg_ParseTuple( args, ‘sO:SetProperty’,@key, @value ) > 0 then       begin         if key = ‘Title’ then           begin             cbTitle.Text := PyObjectAsVariant( value );             Result := ReturnNone;           end         else if key = ‘Name’ then           begin             edName.Text := PyObjectAsVariant( value );             Result := ReturnNone;           end         else if key = ‘Informatician’ then           begin             cbInformatician.Checked := PyObjectAsVariant( value );             Result := ReturnNone;           end         else if key = ‘PythonUser’ then           begin             cbPythonUser.Checked := PyObjectAsVariant( value );             Result := ReturnNone;           end         else if key = ‘Age’ then           begin             edAge.Text := PyObjectAsVariant( value );             Result := ReturnNone;           end         else if key = ‘Sex’ then           begin             rgSex.ItemIndex := PyObjectAsVariant( value );             Result := ReturnNone;           end         else           begin             PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format(‘Unknown property “%s”‘, [key])));             Result := nil;           end;       end     else       Result := nil; end;

Read More

Learn About Using The Windows Subsystem For Linux (WSL) With Delphi

StoreIn this session, you can how to take advantage of the new Windows Subsystem for Linux (WSL) to develop, debug, and deploy Linux applications from Delphi. What is the Windows Subsystem for Linux (WSL) Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019 Multiple distributions are available via the Microsoft Store (Ubuntu, Debian, OpenSUSE, Kali, Fedora e.t.c) Mostly focused on the command-line interface with limited support for GUI apps via the external X11 server Less abstraction and better Windows integration than a traditional Virtual Machine Similar to Hyper-V or Windows Sandbox Invoke Linux binaries from Windows and Windows executables from Linux Be sure to watch the whole session to learn: WSL Installation Managing WSL Distros Targeting from Delphi to Linux  Installation of the PAServer Automation All these steps are shown in action with real demos.

Read More

Powerful Chromium Based WebView Component To Host Web Content In Your Delphi/C++ Builder FireMonkey Apps

RAD Studio 10.4 Sydney brings support for working with web content through the Chromium-based Edge WebView2 browser control in VCL applications via the new TEdgeBrowser component. Embarcadero DocWiki But, this is for only the VCL applications currently. So, what if you want to utilize this feature in your FireMonkey application?! Problem solved! We have the WebView for FireMonkey component by WINSOFT which offers you to host web content in your applications. Uses Microsoft WebView2 API Supports Windows 32 and Windows 64 Available for Delphi/C++ Builder 6 – 10.4 Requires Microsoft Edge (Chromium) version 84.0.515.0 or higher After downloading the WebView component you should install the component. Here you can follow the installation video. Moreover, the WebView2Loader dynamic-link library should be with the executable file. You can find that dynamic-link library from the Library folder within the installed component files. Because the WebView2 is the part of the Microsoft WebView2 SDK. After configuring and installing, you can just create a FireMonkey application and drop the TFWebView component from the System category on the Palette. Using the TFWebView is similar to TWebBrowser or TEdgeBrowser.  Let’s start investigating the features of the TFWebView component. You can give the Uniform Resource Identifier (URI) using the Uri property. With the Zoom property, you can control the view. FWebView.Zoom := FWebView.Zoom – 0.1; FWebView.Zoom := FWebView.Zoom + 0.1; You can fetch the web document title by this code: Caption := ‘WebView – ‘ + FWebView.DocumentTitle; CapturePreview procedure takes a screenshot of the TFWebView component to save the screenshot you can just use the TMemoryStream. Here is a use case. procedure TFormMain.SpeedButtonCaptureClick(Sender: TObject); begin if CapturePreviewStream = nil then CapturePreviewStream := TMemoryStream.Create else CapturePreviewStream.Clear; FWebView.CapturePreview(pfPng, CapturePreviewStream, CapturePreviewCompleted); end; procedure TFormMain.CapturePreviewCompleted(Sender: TObject); const FileName = ‘preview.png’; begin CapturePreviewStream.SaveToFile(FileName); FreeAndNil(CapturePreviewStream); Open(FileName); end; procedure TFormMain.SpeedButtonCaptureClick(Sender: TObject); begin   if CapturePreviewStream = nil then     CapturePreviewStream := TMemoryStream.Create   else     CapturePreviewStream.Clear;   FWebView.CapturePreview(pfPng, CapturePreviewStream, CapturePreviewCompleted); end; procedure TFormMain.CapturePreviewCompleted(Sender: TObject); const FileName = ‘preview.png’; begin   CapturePreviewStream.SaveToFile(FileName);   FreeAndNil(CapturePreviewStream);   Open(FileName); end; TFWebView comes with some amazing functionalities like posting a web message to an HTML document.  Or, showing HTML in memory, like you give the HTML/CSS/JS code as a parameter of the ShowHtml procedure that then creates a document to you within the TFWebView.  Moreover, you can manipulate the HTML document by executing JavaScript code, for instance fetching elements by Id and setting a new value. For this, you can utilize the ExecuteScript procedure. Finally, the best feature is playing with the developer tools. For instance, using Browser methods, like executing the getVersion function. To use this option, you can call the CallDevTools procedure. Be sure to check out part two of this post. In the next one, we will go through these given examples with a full explanation. Head over and check out the full WINSOFT WebView for FireMonkey component.

Read More