unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TStuhlInfo=Record
RGN:HRGN;
Color:TColor;
ID:Integer;
// was auch immer noch benötigt wird
End;
TStuhlArray=Array
of TStuhlInfo;
TForm2 =
class(TForm)
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
FStuhlArray:TStuhlArray;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
type
pArray=Array[0..3]
of TPoint;
var
p:pArray;
begin
// hier nur exemplarisch 1 Stuhl >> wahrscheinlich am besten aus einer Datenbank
SetLength(FStuhlArray,1);
p[0].X := 10;
p[0].y := 10;
p[1].X := 100;
p[1].y := 20;
p[2].X := 90;
p[2].y := 110;
p[3].X := 0;
p[3].y := 100;
FStuhlArray[0].RGN := CreatePolygonRgn(p,4,WINDING);
FStuhlArray[0].Color := clRed;
end;
procedure TForm2.FormDestroy(Sender: TObject);
var
i:Integer;
begin
for I := Low(FStuhlArray)
to High(FStuhlArray)
do Deleteobject(FStuhlArray[i].RGN);
end;
procedure TForm2.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
i:Integer;
begin
for I := Low(FStuhlArray)
to High(FStuhlArray)
do
if PtInRegion(FStuhlArray[i].RGN,x,y)
then Showmessage(IntToStr(i));
end;
procedure TForm2.FormPaint(Sender: TObject);
var
i:Integer;
begin
for I := Low(FStuhlArray)
to High(FStuhlArray)
do
begin
Canvas.Brush.Color := FStuhlArray[i].Color;
FillRgn(Canvas.Handle,FStuhlArray[i].RGN,Canvas.Brush.Handle);
end;
end;
end.