Skip to content

Instantly share code, notes, and snippets.

@DelphiWorlds
Created January 21, 2020 22:28
Show Gist options
  • Save DelphiWorlds/ad3bef11a815f2e43f88ae041fea4024 to your computer and use it in GitHub Desktop.
Save DelphiWorlds/ad3bef11a815f2e43f88ae041fea4024 to your computer and use it in GitHub Desktop.
Implementing an interface via a helper
unit Unit1;
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;
type
ITest = interface(IInterface)
['{685D7A67-35B5-4D53-B568-3F3AD21A6A53}']
procedure Test;
end;
TFormHelper = class helper for TForm
public
procedure Test;
end;
TForm1 = class(TForm, ITest)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{ TFormHelper }
procedure TFormHelper.Test;
begin
Sleep(0); // Put breakpoint here
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
(Self as ITest).Test;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment