Source Code Delphi Samples with Sources

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Generate Cross Platform Dynamic Forms At Runtime From JSON In Delphi
(tested in 10.2.1 Tokyo, but, can work in another version later)
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Webinar by Marcu Cantu, about High DPI crossing 2 display with distinct resolution
2 display with same app (High res 4K and Low res Windows default) on XE10.3 RIO
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
How to update all library paths programmatically for any component
thanks to Devine (unknow by me)
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my sample to Capture screen (contents) from PageControl "TabSheet" (VCL) or "TabItem" (FMX) and save it on Bitmap file or print it!
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Custom Managed Records Coming in Delphi 10.3
Marco Cantu - November 7, 2018
Beside inline variable declarations, Delphi 10.3 is going to offer another new Object Pascal language extension, custom managed records
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Firemonkey: How to crop a photo in Delphi (Video lessons) - in PortugueseBR
Easy method and didatic for crop a image, for example, to create your "profile photo" in your app Mobile or Windows.You can change to VCL!


NOTE: You can change the subtitles for your language (google option for all languages)

One feature that leaves your mobile app with a more professional face is to allow your user to change his or her profile picture. But do not just send the new photo to replace the old image. Ideally, it can resize and crop the photo the way you want.

This feature is used in applications such as Facebook and Twitter, and allows a very nice customization of the photos!

 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
SHA Hash with C++Builder and Delphi
Posted by , 11 MAY 2018 (Embarcadero MVP)
1552103443112

I've always been fascinated by encryption & compression, but my favorite is probably the . A hash function is a one-way algorithm that takes an input of any size and always produces the same size output. It is one-way in that there is information loss -- you can't easily go from the output to the input again. The cryptographic hash is a more secure version of the hash function. It is most often used in signing to validate that data hasn't been modified.
Per , the ideal cryptographic hash function has five main properties:
  • it is so the same message always results in the same hash
  • it is quick to compute the hash value for any given message
  • it is to generate a message from its hash value except by trying all possible messages
  • a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value
  • it is to find two different messages with the same hash value
R7UNC3.png

The Message Digest family of cryptographic hashes used to be the main players in the area, but they were found to be insecure. Now SHA family rules as the main workhorse of modern cryptography.

The basis of hash support first appeared in the RTL around the 2009 release but in (2015) we got the unit, which brought the MD5, SHA-1, and Bob Jenkins hashes. Then in (2015) it was expanded with support. Most recently in (2017) the hash functions were expanded to accept either a string or stream in addition to the original bytes input.

The SHA Family includes SHA-0, SHA-1, SHA-2, & SHA-3 family of hashes. SHA-0 is obsolete, and SHA-3 is an improvement on SHA-2. In practice I see most hashes using either SHA-1 or SHA-2. SHA-1 always produces a 160-bit (20-byte) hash (digest), while SHA-2 includes 224, 256, 384, and 512-bit outputs, making it both more secure and more flexible. SHA 256 & 512 represent 32 and 64-bit word size hash algorithms. The 224, 256, & 384 size digests are truncated versions of the 256 & 512 algorithms.

So how do you use it in C++Builder and Delphi? I'm glad you asked. Once you have included the System.Hash unit then you can use the methods of the THashSHA2 class to create the digest. I'll show you how to use GetHashString, but know there are other variations you can use too. The GetHashString takes either a string or a stream and returns a hexadecimal string of the hash.

In C++Builder your code would look like:
Код:
Edit512->Text = THashSHA2::GetHashString(
    EditMessage->Text,
    THashSHA2::TSHA2Version::SHA512);
and in Delphi your code would look like:
Код:
Edit512.Text := THashSHA2.GetHashString(
    EditMessage.Text,
    THashSHA2.TSHA2Version.SHA512).ToUpper;
I made a little sample app that generates all the different hashes from the text you provide. It is a FireMonkey app, so will work on all the platforms, but the hash code will work in any type of app. There are both C++ and Delphi versions included.
TRB50R.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
3D Credits Scroll with Delphi (A little fun with Delphi for today’s Star Wars day!)
by Jim McKeeth, 04/May/2018
A little fun with Delphi for today’s Star Wars day!

This is a pretty simple 3D form with a 3D layout at an angle, and then a 2D layout with text and images is animated up the 3D layout. The only code is populating the labels as the animation kicks off automatically.

1552103527231


1552103537682

change the message to share with your friends. It is FireMonkey, and while I only tested it on Windows, it should work on Android, iOS, macOS, and even Linux if you are running .


May the Fourth be with You!
1552103577588
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
My code to "Counting how many links exist in a webpage or similar content" like email message

CONCLUSION:
- IT WORK, BUT NEED TO BE REFINED. OF COURSE!
- BUT IT IS NOT FOR EXPERT USER, JUST FOR "NOOB" TEST!
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Did you know is possible use VCL and FMX (FireMonkey) togheter in your app?
Here my test about use of "VCL" and "FMX" objects togheter, to create one app to MS Windows!

Many want to use DLLs written in C / C ++ or another language along with their project in RAD Studio (Delphi or CBuilder), but they forget or do not know that a BPL is actually a binary library, such as a DLL, with due exceptions and differences in your call.

However, since a BPL is actually a binary Delphi / CBuilder code container, then this means you can create your own repository of objects (classes) and codes to use in your projects, in order to re-use their codes. (Remember one of the pillars of object-oriented language - Inheritance)

To use one framework within the other, in the case it may be: VCL within FMX, or FMX within VCL - you have to take a few basic steps.

You must create the objects that will be used by the other framework with a package (BPL / DCP), as RAD Studio does.
In your application project, VCL or FMX, you must inform that you will use a custom "RUNTIME PACKAGE", which is your newly created package.
Add the DCP file - not BPL file ok!
IT's NOT NECESSARY INSTALL THE PACKAGE IN YOUR IDE, JUST HAVE IT TO USE!
By default, RAD Studio saves the BPL and DCP files in your "Documents Public \ Embarcadero \ .... DCP and BPL sub-folders" - if you want, you can "copy it" for you project folder or any other place!
Just DONT FORGET where is it, ok!
After that, you simply inform in your application project, in the "USES" clause, which unit you intend to use, and which is inside your "package" that you created before.
Then you can use the objects and classes as you normally do when using the RAD Studio default packages.
Код:
My project VCL that will use my TForm FMX (FireMonkey)
-------------------------------------------------------------------------------

unit uVCLFormMain;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,
  Vcl.Menus,
  //
  uFMXForm_inVCLproject  // in my package with my objects FMX
  //
    ;

type
  TVCLFormMain = class(TForm)
    Label1: TLabel;
    MainMenu1: TMainMenu;
    Files1: TMenuItem;
    About1: TMenuItem;
    CallFMXform1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    procedure CallFMXform1Click(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  VCLFormMain: TVCLFormMain;

implementation

{$R *.dfm}

procedure TVCLFormMain.CallFMXform1Click(Sender: TObject);
var
  lFMXForm_inVCLprj: TfrmFMXForm_inVCLproject;
begin
  lFMXForm_inVCLprj := TfrmFMXForm_inVCLproject.Create(nil);
  try
    lFMXForm_inVCLprj.ShowModal;
  finally
    Self.SetFocus;
    //
    lFMXForm_inVCLprj.DisposeOf;
    lFMXForm_inVCLprj := nil;
  end;
end;

procedure TVCLFormMain.Exit1Click(Sender: TObject);
begin
  Close;
end;

end.


my TForm FireMonkey (FMX) used in my VCL project
-------------------------------------------------------------------------------

unit uFMXForm_inVCLproject;

interface

uses
  System.SysUtils,
  System.Types,
  System.UITypes,
  System.Classes,
  System.Variants,
  FMX.Types,
  FMX.Controls,
  FMX.Forms,
  FMX.Graphics,
  FMX.Dialogs,
  FMX.Layouts,
  FMX.StdCtrls,
  FMX.Controls.Presentation;

type
  TfrmFMXForm_inVCLproject = class(TForm)
    AniIndicator1: TAniIndicator;
    Layout1: TLayout;
    Label1: TLabel;
    StyleBook1: TStyleBook;
    ToolBar1: TToolBar;
    sbtnClickMe: TSpeedButton;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure sbtnClickMeClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmFMXForm_inVCLproject: TfrmFMXForm_inVCLproject;

implementation

{$R *.fmx}

procedure TfrmFMXForm_inVCLproject.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  AniIndicator1.Enabled := False;
end;

procedure TfrmFMXForm_inVCLproject.FormCreate(Sender: TObject);
begin
  Position := TFormPosition.ScreenCenter;
end;

procedure TfrmFMXForm_inVCLproject.FormShow(Sender: TObject);
begin
  AniIndicator1.Enabled := False;
  AniIndicator1.Enabled := True;
end;

procedure TfrmFMXForm_inVCLproject.sbtnClickMeClick(Sender: TObject);
begin
  ShowMessage('Hello FMX project');
end;

end.


my project FireMonkey (FMX) that will use my TForm VCL
-------------------------------------------------------------------------------

unit uFMXFormMain;

interface

uses
  System.SysUtils,
  System.Types,
  System.UITypes,
  System.Classes,
  System.Variants,
  FMX.Types,
  FMX.Controls,
  FMX.Forms,
  FMX.Graphics,
  FMX.Dialogs,
  FMX.Controls.Presentation,
  FMX.StdCtrls,
  FMX.Layouts,
  //
  uVCLForm_inFMXproject  // in my package with my objects VCL
  //
    ;

type
  TFMXFormMain = class(TForm)
    Layout1: TLayout;
    ToolBar1: TToolBar;
    sbtnCallVCLForm: TSpeedButton;
    sbtnCloseApp: TSpeedButton;
    Label1: TLabel;
    StyleBook1: TStyleBook;
    procedure FormCreate(Sender: TObject);
    procedure sbtnCallVCLFormClick(Sender: TObject);
    procedure sbtnCloseAppClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMXFormMain: TFMXFormMain;

implementation

{$R *.fmx}

procedure TFMXFormMain.FormCreate(Sender: TObject);
begin
  Position := TFormPosition.ScreenCenter;
end;

procedure TFMXFormMain.sbtnCallVCLFormClick(Sender: TObject);
var
  lVCLForm_inFMXprj: TfrmVCLForm_inFMXproject; // my TForm VCL
begin
  lVCLForm_inFMXprj := TfrmVCLForm_inFMXproject.Create(nil);
  try
    lVCLForm_inFMXprj.ShowModal;
  finally
    Self.Active := True;
    //
    lVCLForm_inFMXprj.DisposeOf;
    lVCLForm_inFMXprj := nil;
  end;
end;

procedure TFMXFormMain.sbtnCloseAppClick(Sender: TObject);
begin
  Close;
end;

end.
-------------------------------------------------------------------------------

my TForm VCL used in my project FireMonkey (FMX)
-------------------------------------------------------------------------------

unit uVCLForm_inFMXproject;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,
  Vcl.ExtCtrls,
  Vcl.ComCtrls,
  Vcl.ToolWin,
  Vcl.Menus,
  System.ImageList,
  Vcl.ImgList,
  System.Actions,
  Vcl.ActnList,
  Vcl.StdActns,
  Vcl.Themes;

type
  TfrmVCLForm_inFMXproject = class(TForm)
    Label1: TLabel;
    Panel1: TPanel;
    Animate1: TAnimate;
    ToolBar1: TToolBar;
    Button1: TButton;
    Button2: TButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ComboBox1: TComboBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmVCLForm_inFMXproject: TfrmVCLForm_inFMXproject;

implementation

{$R *.dfm}

const
  lPathStyles = 'C:\Users\Public\Documents\Embarcadero\Studio\20.0\Styles';

procedure TfrmVCLForm_inFMXproject.Button1Click(Sender: TObject);
begin
  ShowMessage('Hello VCL project');
end;

procedure TfrmVCLForm_inFMXproject.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmVCLForm_inFMXproject.ComboBox1Change(Sender: TObject);
begin
  if (ComboBox1.Items.Count > 0) then
    TStyleManager.SetStyle(ComboBox1.Text);
end;

procedure TfrmVCLForm_inFMXproject.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Animate1.Active := False;
end;

procedure TfrmVCLForm_inFMXproject.FormCreate(Sender: TObject);
var
  lStyleName: string;
begin
  Position := TPosition.poScreenCenter;
  //
  for lStyleName in TStyleManager.StyleNames do
    ComboBox1.Items.Add(lStyleName);
  //
  if (ComboBox1.Items.Count > 0) then
    ComboBox1.ItemIndex := 0;
end;

procedure TfrmVCLForm_inFMXproject.FormShow(Sender: TObject);
begin
  Animate1.Active := False;
  Animate1.Active := True;
end;

initialization

finalization

end.
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
here my examples of:
- Creating Columns by code in StringGrid in VCL and FireMonkey (FMX)
- VCL project

Screen002.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
- Creating Columns by code in StringGrid in VCL and FireMonkey (FMX)
- FMX project

Screen001.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my project test, VCL / FMX using LiveBinding to link my Class TPersons with my StringGird
thanks to Thulio Bittencourt MVP Embarcadero Brasil
using POO code and manual instructions to link my TPersons class to the component StringGrid

Screen-Live-Binding-and-Code-POO-FMX-example.png

Screen-Live-Binding-and-Code-POO-VCL-example.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my example for add Tag in TreeNode from TreeView and delete any item indicated by Tag
  • Like imitating a TAG property from components, using a OBJECT (in true, a Type RECORD with a field) - so easy!
  • Then, stay more easy find any TreeNode with a specific value on new "Tag" attribute
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
InLine variable declaration, WORKS, if used correctly
my example in RAD Studio 10.3.1 Arch
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Learn How To Deploy Delphi 10.3 Rio Android Apps To Google Play With Android 64-bit Requirements
July 18, 2019 by Admin FmxExpress.com
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
When a Exception is raised on Constructor or Destructor from a Class
thanks to Alister Christie
Testing-Raise-Exceptions-in-Constructor-and-Destructor-from-Objects.png


 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my sample using: FireMonkey TScaleLayout, TGridPanelLayout, TLayout and GetScreenOrientation to rotate components using screen orientation from Android
here my sample to show how to rotate components in Firemonkey project accourding with screen orientation
Scenary:
  • RAD Studio 10.3.2 Arch
  • FireMonkey project
  • Smartphone Moto G4 with Android 7.0 Nougat
FMX-Layout-Landscape-Portrait-screenshot.png

Screenshot-20191011-021033.png

Screenshot-20191011-021048.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my sample about: Reading JSON File using TJSONIterator, TJSONTokens and TJSONTextReader classes - Easy mode!

My-Conan-Exiles-Screen0001.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
My sample based on "FireDAC using connections type", webinar showed by Jens Fudge
FireDAC for Windows 10 Database Access by Jens Fudge MVP Embarcadero - webinar


 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
Here my example how to use TVirtualImageList and TImageCollection to store and show images in TImage or similar controls!
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
my VCL project Creating Forms MDI using FormStyle fsMDIForm and fsMDIChild and ProgressBar control on runtime - my sample for remember good-times
Forms-MDI-and-Child-with-Control-Created-in-Run-Time.png
 
Последнее редактирование:

ermax

Well-known member
Команда форума
Moderator
Premium
Регистрация
05.05.2008
Сообщения
2 485
Реакции
2 188
Баллы
113
Местоположение
here and there
Native language | Родной язык
Other language
TEdit accepting only FLOAT values or NOT and some keys from User (NUMBERs, DOT, COMMA, ENTER, BACKSPACE, ESC, etc..)
NOTE: NOT PERFECT OK! :)

Here my simple TEDIT sample for this, of course, is possible using a code more xpert like create a class to automatize all process, or same, use new functions/procedure on RAD Studio 10.3.3 Rio.
Code:
 
Последнее редактирование:
198 074Темы
635 045Сообщения
3 618 392Пользователи
RarterorНовый пользователь
Верх