Noutați

Learn How To Use Return Type Deduction In C++ For Windows Apps

In this tutorial, you will learn how to use return type deduction in C++ Builder. For the C++14 scheme of auto with functions, the compiler can deduce return types for any function, no matter how complex it is. The only requirement is that each return statement needs have the same type. The practices are identical as for auto variables. To deduce the type, the compiler requires to detect the function definition right ahead. That means this technique is limited to function templates, inline functions, and helper functions which are applied only inside a particular translation unit. Here is a code example on return type deduction #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif #include #include class employee { // Lots of code here }; struct person_id { std::string first_name; std::string last_name; }; class employees { public: auto find_employee(const std::string& name) { return 1; } }; int return_an_int() { return 1; } auto return_something() { return 1; } // The following will give a compiler error, because int and // float are different types //auto returnConfusion() { // if (std::rand() %2 == 0) { // return -1; // } else { // return 3.14159; // } //} int main() { auto i{ return_an_int() }; auto j{ return_something() }; // Example of a method with multiple return points, each with different types – an error // auto k {returnConfusion()}; auto employee_list{ std::make_unique() }; auto person = employee_list->find_employee(“Jane Smith”); system(“pause”); return 0; } 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif   #include #include   class employee {     // Lots of code here };   struct person_id {     std::string first_name;     std::string last_name; };   class employees { public:     auto find_employee(const std::string& name) { return 1; } };   int return_an_int() {     return 1; }   auto return_something() {     return 1; }   // The following will give a compiler error, because int and //     float are different types //auto returnConfusion() { //    if (std::rand() %2 == 0) { //        return -1; //    } else { //        return 3.14159; //    } //} int main() {     auto i{ return_an_int() };       auto j{ return_something() };       // Example of a method with multiple return points, each with different types – an error     // auto k {returnConfusion()};       auto employee_list{ std::make_uniqueemployees>() };       auto person = employee_list->find_employee(“Jane Smith”);       system(“pause”);     return 0; } So, return type deduction bypasses undesirable conversions and the removes type changes you must to apply. If there is a possibility to use return type deduction, just apply this technique. Because this can assist to secure the types you utilize more consistently. Check out more modern C++ features over here on GitHub

Read More

FlexCel .NET, .NET5, Blazor and WebAssembly – Part 2

This is the second part of a two-part series where we explore using FlexCel.NET and Blazor. The first part was about running FlexCel in the browser, and now we will explore running it in the server. Generating a “server-side” Blazor app While blazor WebAssembly is the most exciting thing going on right now, we didn’t want to forget that most use cases for FlexCel are server-side. You access a database in your server, generate an Excel/PDF/HTML report with the data, and send it to the client. So for this second part, we wanted to do something not as exciting as a WebAssembly app, but probably more useful. We won’t go into a boring “create an Excel file from a database in the server and send it to the client”, because server-side this is just FlexCel (the full FlexCel, without WebAssembly limitations), so you can use any existing FlexCel example as-is. Then you can find thousands of tutorials on the web about how to send the file you created in the server to the browser for the user to download. What we will do now is adding an SVG chart to the existing “fetching data” example that is created when you create a new Blazor app. We will write the data into an Excel file, use the data to generate a chart, and render the chart in the client. The video is below:

Read More

TMS priority support

“The quality of the question determines the quality of the answer. Ask the right questions and you will get the right answers.” TMS software is committed to always provide you with the best possible priority support. It is therefore important that you send us the correct information. The more complete your question is, the faster we can help you. Our team tries to make the manuals as complete as possible. And additional information is available via demo projects, videos, blog articles and FAQs on the product pages. Do you want to be helped quickly? Follow our guides and information sources: documentation / Manuals Videos Website / TMS Support Center Priority support For user with an active license, priority support is given to questions and issues at the TMS Support Center! Check out our TMS Support Center, maybe your question has already been answered. You can easily find an answer by using keywords / phrases. Private support If there is a reason your question cannot be asked in our public support center, contact us via email and do include following information always with your questions: Registration email / code Product / component Version IDE Screenshots / sample source project + steps Stay up to date:

Read More

Manual uninstall of RAD Studio/Delphi/C++Builder 10.4 Sydney

Launch the License Manager from the bin folder (by default “C:Program Files (x86)EmbarcaderoStudio21.0binLicenseManager.exe”) and delete any trial or beta (Test Field) license that you can find. Check it under “License Details” in the center column. Under your Control Panel’s Program and Features Add/Remove Program uninstall the following entries: RAD Studio 10.4 version 21.0 Please follow these instructions to remove any leftover files:     If Windows 64-bit, remove the C:Program Files (x86)EmbarcaderoStudio21.0 directory (or the custom folder you had used).    Remove the C:UsersPublicDocumentsEmbarcaderoStudio21.0 directory    Remove the C:ProgramDataEmbarcaderoStudio21.0 directory.    Remove the %APPDATA%EmbarcaderoBDS21.0 directory.    Remove the HKEY_CURRENT_USERSOFTWAREEmbarcaderoBDS21.0 registry key    If Windows 64-bit, remove the HKEY_LOCAL_MACHINESOFTWAREWow6432NodeEmbarcaderoBDS21.0    If Windows 64-bit, remove the following files from C:WindowsSysWOW64:        BDEAdmin.*        CC32*.DLL        Midas.*        Xerces*.DLL Field testers should also do the following (and others may want to as well):     Delete the Godzilla license from License manager before uninstalling it or during the installation of RAD Studio 10.4 Sydney If you had problems in the second step (uninstalling from Windows Control Panel), try this Microsoft tool to solve un-installation problems: http://go.microsoft.com/?linkid=9779673

Read More

Easily Create A Python Container Type In Delphi And Execute It In This Windows Sample App

Earlier we learned how to create a Python type using Delphi classes. How about creating a Python type with some containers or collections capabilities in Delphi and accessing its elements? Python4Delphi PyObject contains Type Services routines e.g Basic, Number, Sequence, Mapping which can be overridden with our custom Python Types Delphi classes. This post helps to do that. Python4Delphi Demo27 Sample App shows how to create a Module, Python type, Import the module, and Python Type in a python script, create a sequence type object and access some of the service routines like length, indexing, etc. You can find the Demo27 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 Demo27 Sample 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 use routines AddMethod, AddMethodWithKW, AddDelphiMethod, AddDelphiMethodWithKeywords to add a method which should be type compatible with this routine parameter. You can create events using the Events property. TPythonType: This component helps to create a new python type in Delphi which is inherited from the hierarchy of classes (set of APIs to create, manage methods, and members). 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 Demo27 sample project from the extracted repository ..Python4DelphiDemosDemo27.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 a Module name test is created. In this sample, Created a Delphi class(TMySeq) implementing a new Python type. It is derived from TPyObject. It overrides some Mapping services virtual methods such as MpLength, MpSubscript. function TMySeq.MpLength: NativeInt; begin Result := 10; end; function TMySeq.MpSubscript(obj: PPyObject): PPyObject; begin Result := obj; GetPythonEngine.Py_XINCREF(obj); end; function TMySeq.MpLength: NativeInt; begin   Result := 10; end;   function TMySeq.MpSubscript(obj: PPyObject): PPyObject; begin   Result := obj;   GetPythonEngine.Py_XINCREF(obj); end; During PythonType1 initialization assign the property PyObjectClass with the class TMySeq. procedure TForm1.PythonType1Initialization(Sender: TObject); begin with Sender as TPythonType do PyObjectClass := TMySeq; end; procedure TForm1.PythonType1Initialization(Sender: TObject); begin   with Sender as TPythonType do     PyObjectClass := TMySeq; end; On Clicking Execute Button the below code is executed. procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings(Memo2.Lines); end; procedure TForm1.Button1Click(Sender: TObject); begin   PythonEngine1.ExecStrings(Memo2.Lines); end; Which will execute the python script mentioned below. import test S=test.CreateMySeq() print (S) print (len(S)) print (S[1]) print (S[1,2]) print (S[1:2]) print (S[1:20:2]) print (S[…]) print (S[1,4,5:8, 10:20:2, …]) import test S=test.CreateMySeq() print (S) print (len(S)) print (S[1]) print (S[1,2]) print (S[1:2]) print (S[1:20:2]) print (S[…]) print (S[1,4,5:8, 10:20:2, …]) Note. CreateMySeq in the above script is created automatically by Python4Delphi when the property GenerateCreateFunction of TPythonType1(MySeq) is true. Python4Delphi Demo27

Read More

Popular Enterprise Grade Password Identity Manager Powers 70,000+ Businesses And Is Built In Delphi

1Password is a premier password and identity manager that runs in millions of desktops and mobile devices worldwide and it is built in Delphi. According to their site in addition to personal and family options it also powers the enterprise with more than 70,000 businesses trusting 1Password to secure their business and protect their data. Stefan van As and Mark Eaton from AgileBits provided some information on the third party components that they make use of in the 1Password for Windows version. It really is amazing all of the different components that they make use of from the massive third party component ecosystem available to all Delphi developers. The Delphi developer ecosystem is one of the key things that makes it such a powerful development tool. Here is an overview of the 3rd party components used in 1Password: Browser Helper Objects (BHOs) — this is what powers 1Password inside Internet Explorer, Bonjour — this is what powers Wi-Fi Sync (here is an unrelated Delphi implementation), ChilkatCrypt — this is what powers some of our crypto, MS Crypto — this is the Pseudo Random Number Generator (PRNG), DISQLite — Some of 1Password’s features – such as Watchtower, for example – are utilizing SQLite. Because 1Password 4 is in Delphi 2007, we use DISQLite for that (today, it would be using FireDAC for that), dxgettext — this is used to localize 1Password. It works nicely with Crowdin, a localization project management platform, GraphicEx and Graphics32 — this gives (alpha channel) transparency, HyperString — super fast string handling routines. (no longer available), OpenSSL — this is what powers PBKDF2 (among other crypto routines), sgcWebSockets — The WebSockets are used with the Chrome and Firefox browser extensions, StreamSec — another crypto library, mostly for SSL/TLS, and zlib and LibTar — For OS X-compatible compression routines. Additionally they use EurekaLog — For diagnostics reporting, FinalBuilder — For build management, and Inno Setup — The installation wizard. Website https://1password.com/ Screenshot Gallery

Read More

Learn How To Send Arrays To A PostgreSQL Database Server Using FireDAC In Delphi On Windows

Location You can find the Arrays project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesDBMS SpecificPostgreSQLArrays Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. How to Use the Sample Navigate to the location given above and open PGArrays.dproj. Press F9 or choose Run > Run. Files File in Delphi Contains PGArrays.dprojPGArrays.dpr The project itself. fMain.pasfMain.fmx The main form. Implementation Before running the sample, the main components are configured at design time using the Object Inspector as follows: A TFDConnection object named FDConnection1. This is the FireDAC connection object that the sample uses to connect to a DBMS. The sample sets the ConnectionDefName property to PG_Demo. A TFDQuery object named FDQuery1. This component implements a dataset capable of executing SQL queries. The sample sets its Connection property to FDConnection1 to specify the FireDAC connection object. A TDataSource object named DataSource1. This component provides an interface between a dataset component and data-aware controls on a form. In this sample, it is used to provide communication between the dataset and the grid where the dataset is displayed. To this end, the sample sets the following properties: The DataSet property of DataSource is set to FDQuery1. The DataSource property of DBGrid1 is set to DataSource1. When you run the application, you see a grid, a combo box and two buttons labeled as PG Read and PG Write. The purpose of these components in this sample is the following: TDBGrid – This sample uses the grid to display the arrays. TComboBox – Use the combo box to choose whether to define the array as ftArray or ftDataSet. TButtons – Both buttons have an OnClick event to do the following:Uses the Open method to read the arrays from the database server. The sample displays the arrays on the grid.Press this button to send arrays to a database server. When you press this button, the sample takes the following steps: Uses the Text property of SQL to set the SQL command that FDQuery1 will execute. Sets the TFDParam.DataTypeName to specify the field name as .. Sets the TFDParam.ArrayType property to atTable.Note: If you set it to atArray it does not work. Sets the array size with the TFDParam.ArraySize property. Sets the arrays using the AsStrings property: Sends the arrays to the database server by executing the SQL command specified in the first step. For more information you can refer to the link below: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.PostgreSQL_Arrays_Sample Check out the demo source code for PostgreSQL Arrays in Windows apps here.

Read More

Quickly Learn How To SubClass A Python Type Created In Delphi With This Windows Sample App

import spam   class MyPoint(spam.Point):   def Foo(Self, v):     Self.OffsetBy(v, v)   # old way to create a type instance p = spam.CreatePoint(2, 5) print (p, type(p)) p.OffsetBy( 3, 3 ) print (p.x, p.y) print (“Name =”, p.Name) p.Name = ‘Hello world!’ print (“Name =”, p.Name)   # new way to create a type instance p = spam.Point(2, 5) # no need to use CreateXXX anymore print (p, type(p)) p.OffsetBy( 3, 3 ) print (p.x, p.y)   # create a subtype instance p = MyPoint(2, 5) print (p, type(p)) p.OffsetBy( 3, 3 ) print (p.x, p.y) p.Foo( 4 ) print (p.x, p.y) print (dir(spam)) print (spam.Point) print (“p = “, p, ”  –> “,) if type(p) is spam.Point:   print (“p is a Point”) else:   print (“p is not a point”) p = 2 print (“p = “, p, ”  –> “,) if type(p) is spam.Point:   print (“p is a Point”) else:   print (“p is not a point”) p = spam.CreatePoint(2, 5) try:   print (“raising an error of class EBadPoint”)   p.RaiseError() # it will raise spam.EBadPoint except spam.PointError as what: # this shows you that you can intercept a parent class   print (“Caught an error derived from PointError”)   print (“Error class = “, what.__class__, ”     a =”, what.a, ”   b =”, what.b, ”   c =”, what.c)   # You can raise errors from a Python script too! print (“——————————————————————“) print (“Errors in a Python script”) try:   raise spam.EBadPoint(“this is a test!”) except:   pass   try:   err = spam.EBadPoint()   err.a = 1   err.b = 2   err.c = 3   raise err except spam.PointError as what: # this shows you that you can intercept a parent class   print (“Caught an error derived from PointError”)   print (“Error class = “, what.__class__, ”     a =”, what.a, ”   b =”, what.b, ”   c =”, what.c)   if p == spam.CreatePoint(2, 5):   print (“Equal”) else:   print (“Not equal”)

Read More

Easily Add Slide Animations To Your Cross Platform Apps With Gesture Support In This FireMonkey Sample

In this post, you will discover two different demo application, the first one shows you how to add sliding tabs to an application through the use of multiple tabs with custom settings, next and back buttons, and gesture support. The second sample shows you how to implement a master-detail interface and display the Multiview control as a slide-in drawer, popover menu, docked panel, and more. What can you learn? Tab Control Input Form Creation Gestures Animation and managing the form with custom functions You can get these demo application from GetIt! Be sure to check out more sample applications in GetIt here!

Read More

Powerful Media Player Software Downloaded 19+ Million Times Built In Delphi

ALLPlayer is a powerful media player software that will literally will play almost all the media and formats that you encounter in any given day and it is built in Delphi. According to ALLPlayer it has had over 19 MILLION downloads. It can handle 3G2, AVI, MKV, AVI, FLV, DAT, MOV, M2TS, MP4, 3GP, VOB, MPG, APE, AU, MKA, MP3, OGG, WAV and AC3 formats, as well as DVDs, audio CDs, animated GIFs and any link that you specify. The primary features of ALLPlayer include supporting the vast majority of video and audio media and formats AND automatically searches and downloads matching subtitles for your media files. A companion app also built in Delphi is the ALLMediaServer which allows you to watch movies, listen to music or view photos from your computer on your TV, smartphone or other device compatible with Samsung AllShare DLNA. Website https://www.allplayer.org/ Screenshot Gallery

Read More