Hi there everyone,
I'm trying to port some code from Delphi to Lazarus & part of it is code that allow writing coloured lines to a ListBox. The code in question is as shown below:
procedure TfrmServeur.lbxProcessesDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin
// This draws the items in the Process log in colors to allow quick
// inspection
with Control as TListBox do
begin
Canvas.Brush.Color := Color;
Canvas.FillRect(Rect); <-------- ERROR HERE
Canvas.Font.Color := TColor(Items.Objects[Index]);
Canvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]); <-------- ERROR HERE
end;
end;
procedure TfrmServeur.Log(Msg: string; AColor: TColor);
begin
// Simply adds a new item to the process log and then makes it the
// currently selected item.
lbxProcesses.Items.AddObject(Msg, Pointer(Color)); <-------- ERROR HERE
lbxProcesses.ItemIndex := lbxProcesses.Items.Count - 1;
end;
The first two errors say Error: Wrong number of parameters specified for call to "Rect" and the last error says Error: Incompatible type for arg no. 2: Got "Pointer", expected "TObject".
I would appreciate your help in resolving these errors.
JD