Noutați

Learn About Powerful WebSockets Solutions For Delphi

The WebSocket is a communication protocol, that makes it possible to open a two-way interactive communication session between the user’s browser and a server. With this, you can send messages to a server and receive event-driven responses without having to poll the server for a reply. Applications that require Real-time data streaming, Synchronization uses WebSocket primarily. Most browsers support the protocol, including Google Chrome, Microsoft Edge, Internet Explorer, Firefox, Safari, and Opera. The WebSocket protocol specification defines ws (WebSocket) and wss (WebSocket Secure) as two new uniform resource identifier (URI) schemes that are used for unencrypted and encrypted connections, respectively. Web Socket Server: A WebSocket server is nothing more than an application listening on any port of a TCP server that follows a specific protocol. The task of creating a custom server tends to scare people; however, it can be straightforward to implement a simple WebSocket server on your platform of choice. In Delphi, we can create our own server directly inheriting from Indy TIdCustomTCPServer. WebSocket servers are often separate and specialized servers (for load-balancing or other practical reasons), so you will often use a reverse proxy (such as a regular HTTP server) to detect WebSocket handshakes, pre-process them, and send those clients to a real WebSocket server. Web Socket Handshake: The server must listen for incoming socket connections using a standard TCP socket. Depending on your platform, this may be handled for you automatically. For example, let’s assume that your server is listening on example.com, port 8000, and your socket server responds to GET requests at example.com/chat. Client HandShake: Even though you’re building a server, a client still has to start the WebSocket handshake process by contacting the server and requesting a WebSocket connection. So, you must know how to interpret the client’s request. The client will send a pretty standard HTTP request with headers that looks like this (the HTTP version must be 1.1 or greater, and the method must be GET): GET /chat HTTP/1.1 Host: example.com:8000 Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Version: 13 GET /chat HTTP/1.1 Host: example.com:8000 strong>Upgrade: websocket/strong> strong>Connection: Upgrade/strong> Sec–WebSocket–Key: dGhlIHNhbXBsZSBub25jZQ== Sec–WebSocket–Version: 13 When the server receives the handshake request, it should send back a special response that indicates that the protocol will be changing from HTTP to WebSocket. That header looks something like the following (remember each header line ends with rn and put an extra rn after the last one to indicate the end of the header): HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= strong>HTTP/1.1 101 Switching Protocols/strong> Upgrade: websocket Connection: Upgrade strong>Sec–WebSocket–Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= /strong> Exchanging Data formats : Message is Exchanged in certain formats Between client and server called “Frames”. For more information check here. Existing Solutions Available : Check the video for creating web sockets server and client implementation in Delphi below. WebSocket And Delphi

Read More

Quickly Build C++ Builder Application And Connect To Microsoft Excel Using ADO

Connecting and Read/Write to Microsoft Excel becomes a common need among many Applications. How to do with ADO connection in your C++ Builder Application? This Post guide will you to do that and its very simple steps. Assume you need to create a application, Read data from excel and populate into a Grid, and need to write data to the excel. To do this four components required, TADOConnection: TADOConnection encapsulates the ADO connection object. Use TADOConnection for connecting to ADO data stores(e.g Excel). The connection provided by a single TADOConnection component can be shared by multiple ADO command and dataset components through their Connection properties. TADOConnection allows you to control the attributes and conditions of a connection to a data store. TADOQuery: To access one or more tables( In Excel, it is sheet) in a data store using SQL statements. Retrieve data from tables in an ADO data store using SELECT statements. Perform actions on tables and other metadata objects in an ADO data store with statements like INSERT, DELETE, UPDATE, ALTER TABLE, and CREATE TABLE. Execute stored procedures.   TDataSource: To provide a conduit between a dataset and data-aware controls on a form that enable display, navigation, and editing of the data underlying the dataset.  TDBGrid: Displays and manipulates records from a dataset in a tabular grid. Applications can use the data grid to insert, delete, or edit data in the database, or simply to display it. Steps to connect to Excel using ADO Connection: Create a new Windows VCL C++ Application. Add these components TADOconnection, TADOQuery, TDataSource, TDBGrid, TCombox, and TButton. Set the ADOquery and DBGrid Datasource property with TDatasource instance. Assign the TADOConnection.Connectionstring with “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:YourExcel.xls;Extended Properties=”Excel 8.0”; Populate the tables(sheet list) into the combobox from TADOconnection.GetTableNames(StringList). On Button click set TADOQuery SQL string with “select * from ” and open the TADOQuery. Check the video for demonstration.

Read More

Learn How Easy It Is To Connect To Microsoft SQL Server Using FireDAC In RAD Studio

Connecting to Multiple Enterprise Databases is no more a time consuming task in making connections and login to databases. FireDAC is a Universal Data Access library for developing applications for multiple devices, connected to enterprise databases. With its powerful universal architecture, FireDAC enables native high-speed direct access from Delphi and C++Builder to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, DB2, SQL Anywhere, Advantage DB, Firebird, Access, Informix, DataSnap, and more, including the NoSQL Database MongoDB. How To Connect With Microsoft SQL Server using FireDAC. Prerequisites : Ensure Native Microsoft SQL server latest driver is installed and a Microsoft SQL Server installed machine (local or Remote) to connect database. Open RAD Studio 10.4.1 -> Navigate to Data Explorer -> Expand FireDAC -> Select Microsoft SQL Server. Right Click Add New Connection. Enter the name of the Connection e.g) NorthWind. FireDac Conenction editor is opened with DriverID ‘MSSQL’ Provide the Server, Database, Username, Password to connect. Click the Test Button to check the connection. FireDAC login window with details will be shown. Click Ok. Connection Successful message will be popped up. Lot of other options available for your connection establisment. Check out the documentation here. Once Successful connection is made, Expand the database which is connected e.g Northwind, you can Expand Tables, Views. Create a new Windows VCL Application. Drag and Drop the Table e.g Employee. Select the Table and in Object Inspector set the property Active to true. Right Click Bind Visually, Which opens the LiveBindings Designer with the TableName. Select * in the Table Row. RightClick Link to new Control… Select TStringGrid. That’s all, Table data is populated to String Grid in the Form. These 10 Simple steps is enough to make your connection with Microsoft SQL Server. Check out the Demonstration here. Universal FireDAC Connectivity Architecture: FireDAC Architecture. FireDAC Features : Data Access Engine : Lightweight, effective and flexible engine can be used directly in applications and serves as a powerful foundation to the datasets API.  Unified API : FireDAC provides a range of features that help abstract the differences between database systems, making it easy to write code that does not have to be concerned about different DBMS dialects or other subtle differences between DBMSs. High- Performance Data Access : Database access is optimized using many different techniques often found only in database-specific components, which let you get faster data access out of the box. To get started with FireDAC and benefits it offers for developers Check here.

Read More

Learn How to Build High-Performance Real-Time Apps With Delphi And SignalR

In this CodeRage session, we’ll create a simple real-time multi-platform chat application in RAD Studio using the Devart SecureBridge component called TScHubConnection, which implements the functionality of a SignalR client. What can you do with SignalR? While chat is often used as an example, you can do a whole lot more. Any time a user refreshes a web page to see new data, or the page implements Ajax long polling to retrieve new data, it’s a nominee for using SignalR. SignalR also enables completely new types of applications that require high-frequency updates from the server, such as real-time gaming. SignalR library has been implemented in many languages already and the solution by Devart is a great option.  Be sure to watch the CodeRage session where you can learn how you can implement such functionalities in your Delphi applications.  Here you can learn more about the SecureBridge component at Devart.

Read More

Learn How To Take Your Cross-Platform Development To The Next Level With Delphi FireUI

With the all-new FireUI Multi-Device Designer, design user interfaces across multiple devices using a master form to share all user interface code, then optimize derived views for each target platform and device. The existing native Desktop styles have been extended to cover the same UI elements as mobile styles, providing a 1:1 match with universal styling support across all platforms, giving the native look and feel on each supported platform. FireUI Multi-Device Designer provides a set of predefined views, including Windows Desktop, Surface Pro Tablet, Mac Desktop, iPhone, iPad, Android Tablets, and Smart Phones, and wearables like Smart Watches. FireUI: Revolutionary Multi-Device Development Devices are everywhere and users’ expectations are higher than they have ever been. Customers expect to be able to use an application on their smartphone while on the go and then switch to their tablet or Desktop computer while in their office or at home. Optimizing user interfaces for each of these device form factors can be challenging and costly, efficiently building multiple separate form views for each device. Multi-Device development is radically simplified with the FireUI design paradigm, tools, and components, delivering more productivity than ever before.

Read More

Quickly Learn About The Ultimate Open Tools APIs For Decorating Your Delphi/C++ Builder IDE

Though RAD Studio IDE supports a lot of features to boost productivity sometimes as a Delphi/C++ Builder Developer and as an end-user we may think to modify/extend the IDE capabilities for our own custom needs. Don’t know where to start with? Don’t worry! Delphi/C++ Builder has the Flexibility to extend the IDE capabilities using the Open Tools API. Using this Developers can extend some text, graphics, and installs to the IDE. Open Tools API (OTA) The Open Tools API (OTA) is a set of interfaces that allow developers to add features to the BDS, Delphi, and C++Builder IDEs. These additions are called wizards or experts. Wizards can use the OTA interfaces to modify the IDE, obtain information about the IDE’s state, and receive notification of important events. Check some useful FAQs here How to decorate your Editor using OTA: e.g) Need to do visualization of code coverage in the Delphi Source editor with some Text and Graphics representation. How to decorate your IDE with symbols and graphics to the Source editor? How to make sure that these decorations are in sync when editing the content? In ToolsAPI.pas, a lot of interfaces available to Modify IDE, information about IDE’s state, etc. For Visualizing code coverage in the Source editor, use the INTAEditViewNotifier interface PaintLine procedure. Create the Canvas state and draw the graphics required in the implementation of the procedure. procedure PaintLine(const View: IOTAEditView; LineNumber: Integer; const LineText: PAnsiChar; const TextWidth: Word; const LineAttributes: TOTAAttributeArray; const Canvas: TCanvas; const TextRect: TRect; const LineRect: TRect; const CellSize: TSize); procedure PaintLine(const View: IOTAEditView; LineNumber: Integer; const LineText: PAnsiChar; const TextWidth: Word; const LineAttributes: TOTAAttributeArray; const Canvas: TCanvas; const TextRect: TRect; const LineRect: TRect; const CellSize: TSize); BeginPaint is called before the code editor is repainted, and use the EndPaint procedure to clean up any data structures that have been maintained over the course ofpainting lines. Check the below Video Demonstration for decorating the Source Editor. https://www.youtube.com/watch?v=wlH4IVrhqRQ

Read More

Building a C++ VCL Customer/Sales Master/Detail/Charting Application with 1 Line of Code

object MasterDetailForm: TMasterDetailForm   Left = 0   Top = 0   Caption = ‘Customer and Orders Master Detail Using Live Bindings (C++ VCL)’   ClientHeight = 509   ClientWidth = 736   Color = clBtnFace   Font.Charset = DEFAULT_CHARSET   Font.Color = clWindowText   Font.Height = –11   Font.Name = ‘Tahoma’   Font.Style = []   OldCreateOrder = False   OnShow = FormShow   PixelsPerInch = 96   TextHeight = 13   object Splitter1: TSplitter     Left = 0     Top = 161     Width = 736     Height = 3     Cursor = crVSplit     Align = alTop     ExplicitLeft = 24     ExplicitTop = 210     ExplicitWidth = 159   end   object Panel1: TPanel     Left = 0     Top = 0     Width = 736     Height = 33     Align = alTop     TabOrder = 0     object DBNavigator1: TDBNavigator       Left = 159       Top = 4       Width = 225       Height = 23       DataSource = CustomerDataSource       VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast, nbRefresh]       TabOrder = 0     end     object DatabaseActiveCheckBox: TCheckBox       Left = 24       Top = 9       Width = 97       Height = 17       Caption = ‘Database Active’       TabOrder = 1     end   end   object CustomerDBGrid: TDBGrid     Left = 0     Top = 33     Width = 736     Height = 128     Align = alTop     DataSource = CustomerDataSource     TabOrder = 1     TitleFont.Charset = DEFAULT_CHARSET     TitleFont.Color = clWindowText     TitleFont.Height = –11     TitleFont.Name = ‘Tahoma’     TitleFont.Style = []   end   object Panel2: TPanel     Left = 0     Top = 164     Width = 736     Height = 345     Align = alClient     TabOrder = 2     object Splitter2: TSplitter       Left = 305       Top = 1       Height = 343       ExplicitLeft = 208       ExplicitTop = 120       ExplicitHeight = 100     end     object SalesDBGrid: TDBGrid       Left = 1       Top = 1       Width = 304       Height = 343       Align = alLeft       DataSource = SalesDataSource       TabOrder = 0       TitleFont.Charset = DEFAULT_CHARSET       TitleFont.Color = clWindowText       TitleFont.Height = –11       TitleFont.Name = ‘Tahoma’       TitleFont.Style = []     end     object DBChart1: TDBChart       Left = 308       Top = 1       Width = 427       Height = 343       Title.Text.Strings = (         ‘Sales by Item Type for Customer’)       View3DOptions.Elevation = 315       View3DOptions.Orthogonal = False       View3DOptions.Perspective = 0       View3DOptions.Rotation = 360       Align = alClient       TabOrder = 1       DefaultCanvas = ‘TGDIPlusCanvas’       ColorPaletteIndex = 13       object Series1: TPieSeries         DataSource = SalesByItemTypeForCustomerQuery         XLabelsSource = ‘ITEM_TYPE’         XValues.Order = loAscending         YValues.Name = ‘Pie’         YValues.Order = loNone         YValues.ValueSource = ‘SUM’         Frame.InnerBrush.BackColor = clRed         Frame.InnerBrush.Gradient.EndColor = clGray         Frame.InnerBrush.Gradient.MidColor = clWhite         Frame.InnerBrush.Gradient.StartColor = 4210752         Frame.InnerBrush.Gradient.Visible = True         Frame.MiddleBrush.BackColor = clYellow         Frame.MiddleBrush.Gradient.EndColor = 8553090         Frame.MiddleBrush.Gradient.MidColor = clWhite         Frame.MiddleBrush.Gradient.StartColor = clGray         Frame.MiddleBrush.Gradient.Visible = True         Frame.OuterBrush.BackColor = clGreen         Frame.OuterBrush.Gradient.EndColor = 4210752         Frame.OuterBrush.Gradient.MidColor = clWhite         Frame.OuterBrush.Gradient.StartColor = clSilver         Frame.OuterBrush.Gradient.Visible = True         Frame.Width = 4         OtherSlice.Legend.Visible = False       end     end   end   object DatabaseConnection: TFDConnection     Params.Strings = (                ‘Database=C:UsersPublicDocumentsEmbarcaderoStudio21.0Sampl’ +         ‘esDataEMPLOYEE.GDB’       ‘ConnectionDef=EMPLOYEE’)     Connected = True     LoginPrompt = False     Left = 104     Top = 64   end   object CustomerQuery: TFDQuery     AfterScroll = CustomerQueryAfterScroll     Connection = DatabaseConnection     SQL.Strings = (       ‘select * from customer’)     Left = 240     Top = 72     object CustomerQueryCUST_NO: TFDAutoIncField       FieldName = ‘CUST_NO’       Origin = ‘CUST_NO’       ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]       IdentityInsert = True     end     object CustomerQueryCUSTOMER: TStringField       FieldName = ‘CUSTOMER’       Origin = ‘CUSTOMER’       Required = True       Size = 25     end     object CustomerQueryCITY: TStringField       FieldName = ‘CITY’       Origin = ‘CITY’       Size = 25     end     object CustomerQuerySTATE_PROVINCE: TStringField       FieldName = ‘STATE_PROVINCE’       Origin = ‘STATE_PROVINCE’       Size = 15     end     object CustomerQueryCOUNTRY: TStringField       FieldName = ‘COUNTRY’       Origin = ‘COUNTRY’       Size = 15     end     object CustomerQueryPOSTAL_CODE: TStringField       FieldName = ‘POSTAL_CODE’       Origin = ‘POSTAL_CODE’       Size = 12     end     object CustomerQueryON_HOLD: TStringField       AutoGenerateValue = arDefault       FieldName = ‘ON_HOLD’       Origin […]

Read More

Web Application Development using Delphi/C++ Builder

Choosing the Web framework for Delphi/C++ Builder will no longer be a tough task for developers or companies to meet the business needs. There is plenty of resources around Embarcadero and the web about various frameworks with the pros and cons. Struggling to choose the right one for your need? Not to worry, this post will guide you through some of the available frameworks. RAD Studio Included Server Technologies : RAD Studio Included Client Technologies : Which includes REST Backend as a Service (BaaS) Client, Cloud Client libraries, REST Client libraries, SOAP Clients. 3rd Party Web Frameworks: Client Focused: Pascal->JavaScript Transpilers. Write in Object Pascal and translate/Compiles into JavaScript. Creates a pure Web client Solution. Compatible with many popular server solutions. Full Stack or Client/Server Focused: Framework covers the Server app and client interface. Balanced Approach good to choose when Both Server and Visually designed UI is one project. WebBroker is the core of the server for most frameworks listed below. Server Focused Open Source:

Read More

How To Migrate Your Legacy C++ Applications To The Latest Blazing-Fast Version

Thinking to migrate your Legacy C++Builder Applications to the Latest Delphi? Curious to know the things to do and tips to do effortless migrations? This post will guide you through the considerations for successful migrations Things to consider : Unicode Compatibility – Unicode support was added to RAD Studio, Delphi and C++Builder starting with the 2009 version. Many migration resources were developed at that time but are still useful today if upgrading from a pre-Unicode (2007 or earlier) version. Unicode Statistics Tool on your Delphi application and check if any Unicode changes are needed.This Unicode Statistics Tool will assist you in collecting useful statistics for the time and effort needed to migrate your Delphi applications to Unicode. More Resources for Unicode. 64 bit Migration -Ever since Delphi XE2, it has been possible to generate Delphi 64bit applications from the same code base as your traditional Windows 32bit Delphi code. The business case for 64-bit for business is covered in this tech paper The Impact of 64-bit Applications to your Company’s Bottom Line Database and Middleware -The Borland Database Engine (BDE) has been deprecated, and beginning with version XE8 the BDE has been removed from the Delphi installation, but is still available as a separate download from Code Central. All applications using the BDE are recommended to be migrated to FireDAC. If you are new to FireDAC Data Access Components, start here and look at the First Steps and Getting Started links. 3rd party Components : The 3rd party plug-ins (libraries) need to be rebuilt in the current Delphi version. Having the source code makes this easier. You will need to re-compile your 3rd party components / libraries from older Delphi using the current Delphi 10.4.1 version so the components and libraries can be used in current Delphi projects.Check this link for some of the third party components available with RAD Studio and you can search all tools and components on the Embarcadero Technology Partner Directory. Tips for successful migrations : Before Migration: Set an Objective like Why do we need to migrate? What do you want to Mograte to ? Verify availability of Third party applications. Look for Alternatives in GetIt/GitHub/Others. Will help to validate post migrations. BuildTime: Verify Project options , Compiler Version directives, Solve dependencies and your own code, Solve Hints and Warnings. Stabilization: Verify to stabilization by doing some functional tests, corrections of errors, acceptance test Modernization: Look out the modern features which latest version supports such as Use of Styles, Windows/High DPI themes. Use of panels Card,Grid,Stack,Flow. Migration from Client/server to Multi layered Application, Web frameworks, Multiplatform application. Look out the Latest Version Feature Matrix here. Watch the YouTube Video on Migration with Demonstration Webinar Replay for Delphi here. Watch the webinar on Migrating and Modernizing Legacy C++ Applications here.

Read More

OAuth2.0 With The Rest Client Components For C++ Builder

Authentication becomes a critical part of any business, that too developing applications using the OAuth2.0 protocol is still challenging to some C++Builder developers using Restful APIs as most modern IoT applications mandates. Don’t worry, this post will simplify your challenge and understand better. Assume an end-user(Resource Owner) has an account in google(Resource Server) and has resources like contacts. The same user wants to sign up in Facebook (Third-Party App), as a user, he needs to reuse users credentials of google in Facebook and avoid fresh signup(filling all the personal details in Facebook and creating login credentials orto access some of the protected resources from google e.g) use contacts from google to invite friends that need to be used on Facebook. This is achieved by traditional Client Server authentication. But this approach has drawbacks as mentioned below. End user credentials is used by 3rd party app. 3rd party app store credentials for later use. Resource servers must provide password authentication. End users cannot revoke access to individual 3rd party app as credential are universal, can only block access by changing password. Compromise of 3rd party app exposes end user password. OAuth2.0 addresses these issues by introducing an authorization layer and separating the role of the client from that of the resource owner. Instead of using the resource owner’s credentials to access protected resources, the client obtains an access token — a string denoting a specific scope, lifetime, and other access attributes. Access tokens are issued to third-party clients by an authorization server with the approval of the resource owner. The client uses the access token to access the protected resources hosted by the resource server. For above scenario, an end-user (resource owner) can grant facebook (client- webapp, browser, desktop app) access to his protected contacts stored at a google contacts (resource server), without sharing his username and password with the facebook client to invite friends. Instead, he authenticates directly with a server trusted by the contact service(authorization server), which issues the contacts service delegation-specific credentials (access token). End user data is exposed over a Restful API. All transaction is over HTTP/HTTPS. REST – Representational state transfer web services are known as Restful APIs is an architecture style not a protocol. It exposes end user data (XML or typically JSON) by creating URI and transfer over a HTTP protocol. For RestDemo Sample click here. OAuth2.0 Work Flow. Authorization Grant Types: It can be Authorization code, Implicit, Resource owner credentials, Client Credentials. OAuth2.0 and the Internet Of Things: IoT Gadgets and Devices vast of amount of data which can be Applied with analytics which can creates revenue stream. Many IoT Vendors expose end user data over Restful services. Be aware of Vendor Restful API restrictions such as Rate limiting, time and changes in vendor API may result in feature breaking in your client Application. To avoid such limitations you can check Embercadero’s Enterprise Mobility Services Middleware. Okay, this would have helped in understanding the concepts about OAuth2.0 and IoT Use cases. To check the demonstration in action checkout this below one.

Read More