unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 =
class(TForm)
PaintBox1: TPaintBox;
procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
// Variable für Ecken
ecke: integer;
// Variable für Array d. Punkte
points:
array[0..2]
of TPoint;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
points[ecke-1].X := X;
points[ecke-1].Y := Y;
Inc(ecke);
if ecke = 4
then
begin
with Form1.PaintBox1
do
begin
Canvas.MoveTo(points[0].X, points[0].Y);
Canvas.LineTo(points[1].X, points[1].Y);
Canvas.MoveTo(points[1].X, points[1].Y);
Canvas.LineTo(points[2].X, points[2].Y);
Canvas.MoveTo(points[2].X, points[2].Y);
Canvas.LineTo(points[0].X, points[0].Y);
end;
ecke := 1;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ecke := 1;
end;
end.