unit Main_FormU;
interface
uses
Outputter,
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ExtCtrls;
type
TMain_Form =
class( TForm )
Output_RadioGroup : TRadioGroup;
Hello_Button : TButton;
procedure Output_RadioGroupClick( Sender : TObject );
procedure Hello_ButtonClick( Sender : TObject );
private
FOutput : TOutputter;
procedure SetOutput(
const Value : TOutputter );
protected
property Output : TOutputter
read FOutput
write SetOutput;
public
constructor Create( AOwner : TComponent );
override;
destructor Destroy;
override;
end;
var
Main_Form : TMain_Form;
implementation
{$R *.dfm}
uses
Outputter_VCL;
{ TMain_Form }
constructor TMain_Form.Create( AOwner : TComponent );
begin
inherited;
Output := TNullOutputter.Create;
end;
destructor TMain_Form.Destroy;
begin
Output :=
nil;
inherited;
end;
procedure TMain_Form.Hello_ButtonClick( Sender : TObject );
begin
// Ausgabe von "Hello World"
Output.Output( '
Hello World' );
end;
procedure TMain_Form.Output_RadioGroupClick( Sender : TObject );
begin
// Ausgabekanal festlegen
case Output_RadioGroup.ItemIndex
of
0 :
Output := TNullOutputter.Create;
1 :
Output := TMsgOutputter.Create;
2 :
Output := TConsoleOutputter.Create;
3 :
Output := TPrintOutputter.Create;
end;
end;
procedure TMain_Form.SetOutput(
const Value : TOutputter );
begin
if Value = FOutput
then
Exit;
FOutput.Free;
FOutput := Value;
end;
end.