unit unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.StdCtrls, rechteck;
type
TForm1 =
class(TForm)
Button1: TButton;
editx1: TEdit;
edity1: TEdit;
editx2: TEdit;
edity2: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
x1,x2,y1,y2,
breite,hoehe,zustand:Integer;
// Zustand (0,1)
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
TheRect: TRect;
begin
x1:=strtoint(editx1.text);
y1:=strtoint(edity1.text);
x2:=strtoint(editx2.text);
y2:=strtoint(edity2.text);
breite:=x2-x1;
hoehe:=y2-y1;
Canvas.Rectangle(x1, y1, x2, y2);
{Canvas.Rectangle(10, 10, 100, 100);
Canvas.Rectangle(150, 150, 200, 200);
Canvas.Rectangle(350, 350, 300, 300); }
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
form1.Color:=clwhite;
{x1:=10;
x2:=100;
y1:=10;
y2:=100;
breite:=x2-x1;
hoehe:=y2-y1; }
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (X >= x1)
AND (x <= x2)
AND
(y >= y1)
AND (y <= y2)
then
begin
zustand:=1;
end
else
zustand:=0;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if zustand=1
then
begin
form1.canvas.pen.Color:=clwhite;
form1.Canvas.Rectangle(x1,y1,x2,y2);
form1.canvas.pen.Color:=clblack;
x1:=x;
y1:=y;
x2:=x+breite;
y2:=y+hoehe;
form1.Canvas.Rectangle(x1, y1, x2, y2);
end;
end;
end.