(Gast)
n/a Beiträge
|
DrawGrid will nicht anzeigen... :/
16. Feb 2004, 22:18
Moin,
Delphi-Quellcode:
type
TField = class(TDrawGrid)
private
public
constructor Create();
function ReY(Y:Integer; img:TDrawGrid): Integer;
procedure Init;
procedure Refresh(Sender: TObject);
end;
var
Rondo : array[1..4 ] of TRondo;
constructor TField.Create();
begin
inherited Create(nil);
Self.Left := CFieldLe;
Self.Top := CFieldRi;
Self.Width := CFieldWd;
Self.Height := CFieldHt;
Self.ColCount := CCols;
Self.RowCount := CRows;
Self.DefaultColWidth := 60;
Self.DefaultRowHeight := 60;
Self.FixedCols := 0;
Self.FixedRows := 0;
Self.Ctl3D := false;
Self.Options := [goFixedVertLine,goFixedHorzLine,
goVertLine,goHorzLine];
Self.Parent := frmMain;
Self.Canvas.Pen.Color := $00333333;
Self.Canvas.Pen.Width := 5;
Self.OnClick := Self.Refresh;
Self.Init;
end;
procedure TField.Refresh(Sender: TObject);
var a: integer;
begin
for a:=1 to High(Rondo) do Rondo[a].Show;
end;
procedure TField.Init;
var a:Integer;
begin
for a:=1 to High(Rondo) do Rondo[a] := TRondo.Create;
Rondo[1].Init(4,1,P1Col);
Rondo[2].Init(5,1,P1Col);
Rondo[3].Init(4,8,P2Col);
Rondo[4].Init(5,8,P2Col);
end;
Delphi-Quellcode:
type
TRondo = class
private
Fx, Fy, Fr: Integer;
Fcol: TColor;
public
procedure Init(xx,yy: integer; colo:TColor);
procedure Show;
published
property x : Integer read Fx write Fx;
property y : Integer read Fy write Fy;
property r : Integer read Fr write Fr;
property col : TColor read Fcol write Fcol;
end;
procedure TRondo.Init(xx,yy: integer; colo:TColor);
begin
r := CRondoR;
col := colo;
y := yy-1;
x := xx-1;
end;
procedure TRondo.Show;
var b : Tcolor;
oben, links : integer;
begin
oben := Field.CellRect(y,x).Top;
links := Field.CellRect(y,x).Left;
Field.Canvas.Brush.Color := col;
Field.Canvas.Pen.Color := CPCol;
Field.Canvas.Pen.Width := CPWd;
Field.Canvas.Ellipse(oben+(CRondoR-(CRondoR-3)),links+(CRondoR-(CRondoR-3))
,oben+(CRondoR-3),links+(CRondoR-3));
end;
Es funzt nur so Self.OnClick := Self.Refresh;
Wenn ich die Zeile in der Refresh Prozedure am ende der Init Prozedure von Field schreibe dann passiert nichts außer vielleicht mal eine Access Violation...
mfg
NeoXan
|
|
Zitat
|