Thema: Delphi ScrollBar und DrawGrid

Einzelnen Beitrag anzeigen

Benutzerbild von Lannes
Lannes

Registriert seit: 30. Jan 2005
Ort: Münster
745 Beiträge
 
Delphi 3 Professional
 
#6

Re: ScrollBar und DrawGrid

  Alt 11. Mär 2007, 11:11
Hallo,

die Darstellungsprobleme werden, wie marabu schon angedeutet hat, "durch die Art der Farbbestimmung" verursacht. Du legst innerhalb von OnDrawCell bei jedem Aufruf neue Farbwerte fest, hat das einen besonderen Grund?
Legt man die per Random erzeugten Farbwerte z.B. in einem zusätzlichen Array ab, nutzt dieses dann in OnDrawCell, sind alle Probleme der Darstellung nicht mehr vorhanden.

Delphi-Quellcode:
  public
    MyColorArray : Array [0..19,0..19] of TColor;
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var c,r : Integer;
begin
  Randomize;
  with Grid do
    for c := 0 to ColCount -1 do
      for r := 0 to RowCount -1 do
        MyColorArray[c,r] := Random(100000);
end;

procedure TForm1.GridDrawCell(Sender: TObject; aCol, aRow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with Grid.Canvas do
    begin
    Brush.Color := MyColorArray[aCol,aRow];
    FillRect(Rect);
    TextOut(Rect.Left+3,Rect.Top+3,IntToStr(aCol));
    end;
end;
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
  Mit Zitat antworten Zitat