unit Unit6;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
IDisplay =
interface
['
{B515DBE1-9D0E-4491-BEE8-85805852870B}']
function DisplayString:
string;
end;
TEdit =
class(
VCL.StdCtrls.TEdit, IDisplay)
public
function DisplayString:
string;
end;
TLabel =
class(
VCL.StdCtrls.TLabel, IDisplay)
public
function DisplayString:
string;
end;
TComboBox =
class(
VCL.StdCtrls.TComboBox, IDisplay)
public
function DisplayString:
string;
end;
TWuppdi =
class
procedure Consume(
const Display: IDisplay);
end;
TForm6 =
class(TForm)
Edit1: TEdit;
ComboBox1: TComboBox;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
FWuppdi: TWuppdi;
public
{ Public-Deklarationen }
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
{ TEdit }
function TEdit.DisplayString:
string;
begin
Result := Text;
end;
{ TLabel }
function TLabel.DisplayString:
string;
begin
Result := Caption;
end;
{ TComboBox }
function TComboBox.DisplayString:
string;
begin
if ItemIndex > -1
then
Result := Items[ItemIndex]
else
Result := '
';
end;
{ TWuppdi }
procedure TWuppdi.Consume(
const Display: IDisplay);
begin
ShowMessage(Display.DisplayString);
end;
procedure TForm6.Button1Click(Sender: TObject);
begin
FWuppdi.Consume(Edit1);
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
FWuppdi.Consume(ComboBox1);
end;
procedure TForm6.Button3Click(Sender: TObject);
begin
FWuppdi.Consume(Label1);
end;
procedure TForm6.FormCreate(Sender: TObject);
begin
FWuppdi := TWuppdi.Create;
end;
procedure TForm6.FormDestroy(Sender: TObject);
begin
FWuppdi.Free;
end;
end.