Ich versuche gerade mir eine ListBox zu basteln der ich die Schriftfarbe jedes Eintrags mitgeben kann.
Doch komischerweise bekomme ich einen Fehler "Wrong number of Parameters" und (anscheinend als Folgefehler) "Found declaration" (siehe Quellcode)
Auf welcher Leitung stehe ich gerade wieder?
Bitte um Hilfe
Chris
Code: Alles auswählen
unit uFarbListBox;
{$mode ObjFPC}{$H+}
interface
uses
  Classes, SysUtils, Controls, StdCtrls, Graphics;
type
 TFarbListBox = class(TListBox)
  constructor create(AOwner: TComponent);override;
  function Add(const s:string; farbe : TColor):integer;
  procedure OwnDrawItem(Control: TWinControl; Index: Integer;ARect: TRect;State: TOwnerDrawState);
 public
  farben : array of TColor;
 end;
implementation
 procedure TFarbListBox.OwnDrawItem(Control: TWinControl; Index: Integer;ARect: TRect;State: TOwnerDrawState); //-- Error: Found declaration: OwnDrawItem(TWinControl;LongInt;TRect;TOwnerDrawState);
 
 var
   ListBox: TListBox;
   Canvass: TCanvas;
   S: string;
 begin
   ListBox := Control as TListBox;
   Canvass := ListBox.Canvas;
   Canvass.Font.Color := TColor(ListBox.Items.Objects[Index]);
   S := ListBox.Items[Index];
 end;
 function TFarbListBox.Add(const s:string; farbe : TColor):integer;
  var i : integer;
  begin
   i := Items.Add(s);
   setlength(farben,Items.Count);
   farben[i] := farbe;
  end;
 constructor TFarbListBox.create(AOwner: TComponent);
  begin
   inherited create(AOwner);
   Style := lbOwnerDrawFixed;
   setlength(farben,0);
   OnDrawItem := TFarbListBox.OwnDrawItem;   //<-- Error: Wrong number of parameters specified for call to "OwnDrawItem"
  end;
end. 
 Verein
Verein 
 Links
Links Suche
Suche