Moin !
Irgendwas fehlt da noch, denn gezeichnet wird noch nix.
Meine Klasse:
Delphi-Quellcode:
{$M+}
unit Recty;
interface
uses Classes, Graphics, Controls;
type
TRecty =
Class(TGraphicControl)
private
FX, FY,
// X, Y Position (Left Top)
FW, FH : Integer;
// Width, Height
FScale : Double;
// Scaling ...
protected
procedure Paint;
override;
published
// constructor Create();
property X : Integer
read FX
write FX;
property Y : Integer
read FY
write FY;
property W : Integer
read FW
write FW;
property H : Integer
read FH
write FH;
property Scale : Double
read FScale
write FScale;
// Property OnMouseMove;
end;
implementation
procedure TRecty.Paint;
begin
inherited;
Scale := 1;
Canvas.Rectangle(Trunc(X ),
Trunc(Y ),
Trunc((X+W) * Scale),
Trunc((Y+H) * Scale));
end;
end.
Und so erzeuge ich eine Instanz (Items : array of TRecty):
Delphi-Quellcode:
Items[ID] := TRecty.Create(Form1);
Items[ID].Scale := 1;
Items[ID].X := 10;
Items[ID].Y := 10;
Items[ID].W := 30;
Items[ID].H := 30;
// Items[ID].OnMouseMove := nil;
Items[ID].Repaint;
Canvas.Refresh;
Bei dem Paint komme ich allerdings nie an.