[SOLVED] TListBox OnDrawItem problems lazarus / 31-LCL ---------------------------------------------------------------------- JD · 2015-05-05 09:36 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: Code: [Select]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 ---------------------------------------------------------------------- korba812 · 2015-05-05 10:07 Change "Rect" to "ARect" ---------------------------------------------------------------------- JD · 2015-05-05 10:10 Quote from: korba812 on May 05, 2015, 12:07:08 pmChange "Rect" to "ARect" I feel so stupid. Now I see how obvious it was. The parameter was ARect. Thanks a lot for that. It solves the first two errors; now for the one on Pointer(TColor). ---------------------------------------------------------------------- korba812 · 2015-05-05 10:29 Have you tried TObject instead of Pointer? lbxProcesses.Items.AddObject(Msg, TObject(Color)); ---------------------------------------------------------------------- JD · 2015-05-05 10:57 Quote from: korba812 on May 05, 2015, 12:29:15 pmHave you tried TObject instead of Pointer? lbxProcesses.Items.AddObject(Msg, TObject(Color)); Yes I just did & it worked. Thanks a lot.