Skip to content

Instantly share code, notes, and snippets.

View Pasquina's full-sized avatar

Milan Vydareny Pasquina

  • Chicago, Illinois
View GitHub Profile
@Pasquina
Pasquina / VertSBCalc.pas
Created August 10, 2016 17:15
A test item to undershat how this works.
{ This event does 2 things: 1) it obtains the initial value of the Bottom Bound
by checking for a current saved value of zero, and 2) it sets the Bottom Bound
value if the current saved value is non-zero. The current saved value has been
set to zero when the form was created, or to some integer value when the user
has clicked the SBB button. }
procedure TfVertScrollDemo.VertScrollBox1CalcContentBounds(
Sender: TObject;
var ContentBounds: TRectF);
begin
procedure TfVKLogger.FormKeyDown(
Sender: TObject;
var Key: Word;
var KeyChar: Char;
Shift: TShiftState);
begin
if Key = vkReturn then // if Return pressed
begin
Key := vkTab; // change the key to a Tab (causes navigation)
KeyDown(Key, KeyChar, Shift); // execute the form's keydown to effect navigation
@Pasquina
Pasquina / TMDLBO.Create.pas
Created March 25, 2018 19:44
LiveBindings Demo Data Module Constructor
{ The overridden constructor for the data module first creates the data objects that are
displayed by the view. This is done by creating the TCorp object which will cascade
through the TBranch and TEmployee objects to create the entire data tree. It is important
that the data objects be created BEFORE the data module (this form's) objects because the
OnCreate event for the TAdapterBindSource objects will need the data objects to function
properly. This is accomplished by creating TCorp FIRST, and then calling the inherited Create.
The inherited Create will actually create the objects in this TDataModule. }
constructor TMDLBO.Create(AOwner: TComponent);
begin
@Pasquina
Pasquina / TMDLBO.absCorpCreateAdapter.pas
Created March 25, 2018 19:59
LiveBindings Demo Creating the TObjectBindSourceAdapter<TCorp> (Alias CorpObjectBSWrapper)
{ When the Adapter Bind Source for the Corp is created, this event handler creates the
necessary CorpBSWrapper and passes it back to the Bind Source Adapter }
procedure TMDLBO.absCorpCreateAdapter(
Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
{ Begin by creating the CorpWrapper and saving it in the current form }
@Pasquina
Pasquina / DBLBO.TypeAlias.pas
Created March 25, 2018 20:31
LiveBindings Demo Type Aliases
{ These Type Aliases accomplish two things:
1. They eliminate the need to key the cumbersome generic notation every time the type is used
2. They provide meaningful names in place of confusing names used by Live Bindings }
CorpObjectBSWrapper = TObjectBindSourceAdapter<TCorp>; // the corporate object wrapper
BranchListBSWrapper = TListBindSourceAdapter<TBranch>; // the branch object list wrapper
EmployeeListBSWrapper = TListBindSourceAdapter<TEmployee>; // the employee object list wrapper
@Pasquina
Pasquina / TMDLBO.AfterBranchScroll.pas
Created March 25, 2018 20:47
LiveBindings Demo AfterScroll Event Handler
{ When the Branch list changes, either because of a scroll, or add or delete, this routine adjusts the
Employee list to display the appropriate employees }
procedure TMDLBO.AfterBranchScroll(ABindSourceAdapter: TBindSourceAdapter);
var
LBranch: TBranch; // currently displayed Branch
begin
{ A series of casts extracts the current TBranch object being displayed }
@Pasquina
Pasquina / TMDLBO.absBranchesCreateAdapter.pas
Last active March 25, 2018 21:37
LiveBindings Demo Creating the TListBindSourceAdapter<TBranch> (Alias BranchListBSWrapper)
{ When the Adapter Bind Source for Branches is created, this event handler creates the
necessry BranchListBSWrapper and passes it back to the Bind Source Adapter. }
procedure TMDLBO.absBranchesCreateAdapter(
Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
{ Begin by creating the BranchWrapper and saving it in the current form }
@Pasquina
Pasquina / TVLBO.FormCreate.pas
Created March 25, 2018 22:04
LiveBindings Demo FormCreate and FormDestroy
procedure TVLBO.FormCreate(Sender: TObject);
begin
MDLBO := TMDLBO.MDLBOGet;
end;
procedure TVLBO.FormDestroy(Sender: TObject);
begin
MDLBO.Free;
end;
@Pasquina
Pasquina / Simplified Auto Ref Counting.txt
Created September 27, 2020 22:30
A Delphi Console Application to illustrate Automatic Reference Counting (Simplified)
program AutoFreeTest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Classes;
type
IAutoFree = interface
@Pasquina
Pasquina / TGUID.pas
Created November 8, 2020 22:22
VCL Definition of a GUID
PGUID = ^TGUID;
TGUID = record
D1: Cardinal;
D2: Word;
D3: Word;
D4: array[0..7] of Byte;
end;