Delphi

Quickly Build Enterprise-Grade Multi-Tier Solutions Using DataSnap In Delphi And C++

Al Mannarino walks you through how to build a DataSnap solutions project using the DataSnap Setup Wizard. Overview Wizards in the DataSnap Server category DataSnap WebBroker Application Wizard Main components and units Implement the DataSnap server functionality DataSnap Clients DataSnap Use Cases Mainly Delphi and C++ Builder developers utilize 3 major backend technologies: WebBroker – Web Server Application DataSnap – REST Backends RAD Server (EMS) – Most powerful services-based applications When to use DataSnap? A small number of concurrent clients Supports authentication and authorization Support for communication filters Compression and Encryption filters included Callback functionality – Servers can notify selected or all connected client applications by sending information to the callback channels that something interesting happened on the server FireDAC JSON reflection framework – This simplifies building client-server database applications.  If you want to learn how to use DataSnap in your projects, be sure to check out the full, Unleash The Power of Delphi with Delphi Labs DataSnap Series! Take a look at the fixes available in the RAD Studio 10.4 release for DataSnap. Looking for a REST based solution? Try RAD Server!

Read More

Learn About How To Redirect Inserting, Deleting And Updating Records In Delphi With FireDAC

This sample shows how to redirect inserting, deleting and updating records using standalone table adapter. Location You can find the Commands sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesDApt LayerCommands Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. Files File in Delphi Contains Commands.dprojCommands.dpr The project itself. fCommands.pasfCommands.fmx The main form. Implementation The sample implements the following standalone table adapter features. Create table adapter var oAdapt: IFDDAptTableAdapter; begin // create table adapter FDCreateInterface(IFDDAptTableAdapter, oAdapt);   var     oAdapt: IFDDAptTableAdapter;   begin     // create table adapter     FDCreateInterface(IFDDAptTableAdapter, oAdapt); Selecting data with oAdapt do begin FConnIntf.CreateCommand(oComm); SelectCommand := oComm; SelectCommand.Prepare(‘select * from {id FDQA_map1}’); Define; Fetch; //…   with oAdapt do begin     FConnIntf.CreateCommand(oComm);     SelectCommand := oComm;     SelectCommand.Prepare(‘select * from {id FDQA_map1}’);     Define;     Fetch;   //… Redirect records Redirect all record inserts into FDQA_map2 table instead FDQA_map1: FConnIntf.CreateCommand(oComm); InsertCommand := oComm; InsertCommand.CommandText := ‘insert into {id FDQA_map2}(id2, name2) values(:NEW_id1, :NEW_name1)’;   FConnIntf.CreateCommand(oComm);     InsertCommand := oComm;     InsertCommand.CommandText := ‘insert into {id FDQA_map2}(id2, name2) values(:NEW_id1, :NEW_name1)’; Redirect all record deletes into FDQA_map3 table instead FDQA_map1: FConnIntf.CreateCommand(oComm); DeleteCommand := oComm; DeleteCommand.CommandText := ‘delete from {id FDQA_map3} where id3 = :OLD_id1’;     FConnIntf.CreateCommand(oComm);     DeleteCommand := oComm;     DeleteCommand.CommandText := ‘delete from {id FDQA_map3} where id3 = :OLD_id1’; Redirect all record updates into FDQA_map4 table instead FDQA_map1: FConnIntf.CreateCommand(oComm); UpdateCommand := oComm; UpdateCommand.CommandText := ‘update {id FDQA_map4} set id4 = :NEW_id1, name4 = :NEW_name1 where id4 = :OLD_id1’;   FConnIntf.CreateCommand(oComm);     UpdateCommand := oComm;     UpdateCommand.CommandText := ‘update {id FDQA_map4} set id4 = :NEW_id1, name4 = :NEW_name1 where id4 = :OLD_id1’; Add new rows for i := 0 to 4 do DatSTable.Rows.Add([i, ‘string’ + IntToStr(i)]);   for i := 0 to 4 do       DatSTable.Rows.Add([i, ‘string’ + IntToStr(i)]); Post changes to RDBMS For more details and links to other posts, you can refer to the link below: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.DAptLayerCommands_Sample Check out the full source code for the demo over on GitHub or in your RAD Studio IDE examples section.

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

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

TFDBatchMove Is A Powerful Way To Move Data Between Text Files And Tables Using Datasets In Delphi

Location You can find the TFDBatchMove sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDataBaseFireDACSamplesComp LayerTFDBatchMoveMain. How to Use the Sample Navigate to the location given above and open: Press F9 or choose Run > Run. Select one of the following connections from the Use Connection Definition drop-down menu: Access_Demo, Access_Demo_Pooled, SQLite_Demo or SQLite_Demo_Pooled. Click the three buttons to fully test the component behaviour: Click 1. Move text to table to load the data from the Data.txt file into a table. Click 2. Move table to table to move the dataset from one table to a different one. Click 3. Move table to text to move the table content to an output file DataOut.txt. Implementation 1. Move text to table button: This button loads the content from a txt file located at Start | Programs | Embarcadero RAD Studio Sydney | SamplesObject PascalDataBaseFireDACSamplesComp LayerTFDBatchMoveMaindata.txt into a table from the selected DBMS. The sample adds the FireDAC.Comp.BatchMove.Text unit to the interface uses section to allow the creation of a text reader TFDBatchMoveTextReader and a dataset writer TFDBatchMoveDataSetWriter. Sets the FileName property of TFDBatchMoveTextReader with the location of data.txt. This is the file used to load the data to the table. Also several DataDef properties are adjusted according to the text file format. DataDef.Separator := ‘,’; It defines the separator used to separate the fields in the text file. DataDef.WithFieldNames := True; It specifies that the field name is included in the first row of the text file. Uses the Dataset property of TFDBatchMoveDataSetWriter to set the destination dataset. Also Optimise property is set to False to allow the dataset content to be visualized using TDBGrid. The GuessFormat method is called before loading the data to automatically recognize the text file structure. Then the demo executes the TFDBatchMove component and shows the loaded data using a query in the TDBGrid. 2. Move table to table button: This button moves the data between two different tables on the same DBMS. The sample creates a TFDBatchMoveDataSetReader dataset reader and a TFDBatchMoveDataSetWriter dataset writer. Uses the Dataset property of TFDBatchMoveDataSetReader to set the source dataset, qryLoaded. Uses the Dataset property of TFDBatchMoveDataSetWriter to set the destination dataset, qryMoved. It executes the TFDBatchMove component and shows the query of both datasets on the TDBGrid. 3. Move table to text button: This button copies the data from the table source to an output file located at the application’s path. It creates the destination file: DataOut.txt. The sample creates a TFDBatchMoveDataSetReader dataset reader and a TFDBatchMoveTextWriter text writer. Uses the Dataset property of TFDBatchMoveDataSetReader to set the source dataset, qryLoaded. Sets the FileName property of TFDBatchMoveTextWriter to set the output file name and path: Start | Programs | Embarcadero RAD Studio Sydney | SamplesObject PascalDataBaseFireDACSamplesComp LayerTFDBatchMoveMainDataOut.txt. It executes the TFDBatchMove component to create the file and save the data to the output file. You can refer to the link below for more details about this sample: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.TFDBatchMove_Sample Check out the full source code for the TFDBatchMove demo over on GitHub!

Read More

Powerful Cross Platform TeeGrid Is Capable Of Handling A Large Number Of Cells In Delphi FireMonkey

TeeGrid is a full featured third party grid and tabular control for Delphi and C++. Supporting both VCL and FireMonkey it should run on Windows 32 and 64 bit, Mac OSX, Android and iOS. According to the developer it is “Written from scratch (not derived from TCustomGrid or TGrid), aprox 10K lines of code and 100K compiled size. Free for non-commercial use (in binary format).” It claims the only limit is the memory used by your own data, (compile for the 64bit platform for more than 2GB/3GB). Additionally it says that you can use it’s TVirtualModeData class to automatically create columns and provide cell values using OnGet and OnSet events. TeeGrid can be used like a TStringGrid using a TStringsData object: var Data : TStringsData; Data:= TStringsData.Create; // Initialize size Data.Columns:= 2; Data.Rows:= 6; // Set header texts Data.Headers[0]:= ‘A’; Data.Headers[1]:= ‘B’; // Fill rows and cells Data[0,0]:= ‘A0’; Data[1,0]:= ‘B0’; // Set data to grid TeeGrid1.Data:= Data; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 var Data : TStringsData; Data:= TStringsData.Create;   // Initialize size Data.Columns:= 2; Data.Rows:= 6;   // Set header texts Data.Headers[0]:= ‘A’; Data.Headers[1]:= ‘B’;   // Fill rows and cells Data[0,0]:= ‘A0’; Data[1,0]:= ‘B0’;   // Set data to grid TeeGrid1.Data:= Data; Sub-columns (any column can have children columns) TeeGrid1.Columns.AddColumn(‘My Column 1’).Items.AddColumn(‘Sub-Column 1’)… TeeGrid1.Columns.AddColumn(‘My Column 1’).Items.AddColumn(‘Sub-Column 1’)… Per-column formatting (font, back fill, stroke, text alignment, margins) TeeGrid1.Columns[3].ParentFormat:= False; TeeGrid1.Columns[3].Format.Font.Size:= 14; TeeGrid1.Columns[3].TextAlignment:= TColumnTextAlign.Custom; TeeGrid1.Columns[3].TextAlign:= TTextAlign.Center; // or Left or Right TeeGrid1.Columns[3].ParentFormat:= False; TeeGrid1.Columns[3].Format.Font.Size:= 14;   TeeGrid1.Columns[3].TextAlignment:= TColumnTextAlign.Custom; TeeGrid1.Columns[3].TextAlign:= TTextAlign.Center; // or Left or Right Per-cell custom paint using the column OnPaint event Lock columns to left or right grid edges To see the rest of the cells options, go to the next link and download the package: https://github.com/Steema/TeeGrid

Read More

Lovingly Crafted Software To Plan And Simulate Virtual Model Railroads Is Built In Delphi

The 3D Train Studio is an easy-to-use application for planning your perfect model railway and it is built in Delphi. With 3D Train Studio, users can construct their own unique, detailed layouts on their PCs with thousands of tracks to choose from. They can create landscapes consisting of mountains and valleys, place houses and trees along streets and roads and construct their own miniature worlds, with realistic 3D graphics and in real time. Users can also board their virtual model trains and simulate complete rail operations, including animated barriers, signals and road vehicles, automatically or by specially defined events. “We never could have developed 3D Train Studio so efficiently and with such an elegant UI way without Delphi,” said Stefan Werner of 3D Train Studio. On technical side, 3D Train Studio utilizes a lot of different technologies, like a self-written 3D engine capable of rendering thousands of 3D objects in real-time with abstraction of the underlying graphics API (supporting Direct3D 9 and 11), sound processing with the help of the FMOD library, XML-RPC, multi-threading with custom written task manager, custom VCL components for a smooth image viewer, XML processing, multi-language support (currently English and German) and a clean separation of UI, logic and data (MVC). Website https://en.3d-modellbahn.de/ Screenshot Gallery

Read More

Learn How To Use FireDAC In The Dynamic-Link Libraries With DLL Sharing Sample In Delphi

To this end, the sample uses the CliHandle and SharedCliHandle properties of the TFDConnection class. Location You can find the DLLSharing sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesComp LayerTFDConnectionDLL_Sharing 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 Project1.dproj. Press F9 or choose Run > Run. Files File in Delphi Contains Project1.dprojProject1.dpr The project itself. Unit1.pasUnit1.fmx The main form. Project2.dprojProject2.dpr The DLL. Unit2.pasUnit2.fmx The DLL form. Implementation The sample uses FireDAC to implement a connection with a dynamic-link library. To this end, the sample implements three buttons named: Button1, Button2 and Button3. Each button handles a OnClick event to implement the following features: Load a DLL Show data Unload the DLL Load DLL To transfer a connection between an application and a DLL, the sample transfers the TFDCustomConnection.CliHandle property value to the DLL. The handle must be assigned to the TFDCustomConnection.SharedCliHandle property. After the TFDCustomConnection.SharedCliHandle is assigned, the DLL connection can be activated by setting the Connected property to True. Note that there is no need to set up a connection definition, including DriverID. // Application code: FhDll: THandle; // … procedure TForm1.Button1Click(Sender: TObject); begin FhDll := LoadLibrary(PChar(‘Project2.dll’)); @FpShowData := GetProcAddress(FhDll, PChar(‘ShowData’)); end // DLL code: class procedure TForm2.ShowData(ACliHandle: Pointer); var oForm: TForm2; begin oForm := TForm2.Create(Application); oForm.FDConnection1.SharedCliHandle := ACliHandle; oForm.FDConnection1.Connected := True; oForm.FDQuery1.Active := True; oForm.Show; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20   // Application code:   FhDll: THandle;   // …   procedure TForm1.Button1Click(Sender: TObject);   begin     FhDll := LoadLibrary(PChar(‘Project2.dll’));     @FpShowData := GetProcAddress(FhDll, PChar(‘ShowData’));   end   // DLL code:   class procedure TForm2.ShowData(ACliHandle: Pointer);   var     oForm: TForm2;   begin     oForm := TForm2.Create(Application);     oForm.FDConnection1.SharedCliHandle := ACliHandle;     oForm.FDConnection1.Connected := True;     oForm.FDQuery1.Active := True;     oForm.Show;   end; Show data Then, the connection can be used as a normal database connection: TShowDataProc = procedure (ACliHandle: Pointer); stdcall; // … FpShowData: TShowDataProc; // … procedure TForm1.Button3Click(Sender: TObject); begin FpShowData(FDConnection1.CliHandle); end   TShowDataProc = procedure (ACliHandle: Pointer); stdcall;   // …   FpShowData: TShowDataProc;   // …   procedure TForm1.Button3Click(Sender: TObject);   begin     FpShowData(FDConnection1.CliHandle);   end Unload DLL To unload the dynimic-link library, the sample implements the following code: TShutdownProc = procedure; stdcall; // … FpShutdown: TShutdownProc; // … procedure TForm1.Button2Click(Sender: TObject); begin FpShutdown(); FreeLibrary(FhDll); end;   TShutdownProc = procedure; stdcall;   // …   FpShutdown: TShutdownProc;   // …   procedure TForm1.Button2Click(Sender: TObject);   begin     FpShutdown();     FreeLibrary(FhDll);   end; Head over and check out the full sample source code for DLL sharing with FireDAC in Delphi.

Read More

Learn How To Build A REST API App For iOS In 45 Minutes With Delphi

In this CodeRage session, you can find the most valuable information and best practices on building an application for iOS using Delphi FireMonkey. Easily learn how to build a real-world application using Delphi FireMonkey! Overview: Recipes app which fetches data from an open API Deploying to App Store After learning best practices, you can apply to your future projects easily As you walk through the session, you can find interesting approaches for refreshing the recipe list with the TTask. TTask means everything in the inside of the TTask, gonna be executed in the background. As you can see one of the best functionality of the TTask is to prevent the user interface from locking up if you want to start something in the background. And in this case, the response from an endpoint could get more time. Be sure to check out the whole session and learn how to deploy Delphi FireMonkey applications to the App Store! Learn more about using TTask in the parallel programming library. Learn more about deploying your Delphi apps to iOS. Find out more about using the REST debugger in RAD Studio to quickly connect to REST services.

Read More