Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
AW: Viereck zeichnen OOP
22. Jan 2012, 14:56
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Tgeo_objects = class
end;
Tpunkt = class(Tgeo_objects)
x,y:integer;
procedure setx(r:integer);
procedure sety(r:integer);
end;
TLinie = class(Tpunkt)
p1,p2:TPunkt;
end;
TViereck = class(TLinie)
procedure zeichne;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
MyViereck : TViereck;
Punkt : TPunkt;
procedure TViereck.zeichne;
begin
form1.PaintBox1.Canvas.MoveTo(myviereck.x, myviereck.y);
form1.PaintBox1.Canvas.LineTo(myviereck.x + 100, myviereck.y);
end;
procedure tPunkt.setx(r:integer);
begin
x:=r;
end;
procedure Tpunkt.sety(r:integer);
begin
y:=r;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyViereck := TViereck.create;
try
myviereck.setx(7);
myviereck.sety(9);
Myviereck.zeichne;
finally
myviereck.Free;
end;
end;
end.
|
|
Zitat
|