[SOLVED] TreeView onAdvancedCustomDrawItem issue with scrolling lazarus / 31-LCL ---------------------------------------------------------------------- DmytroLev · 2018-10-29 11:33 Hello! I'm trying to put additional information to TreeView in a "column- like" style: (see picture 1 https://drive.google.com/open?id=1AvTcCykHJC13id5jwn06eFziXD1z3p8U). I do it with onAdvancedCustomDrawItem, drawing necessary info to Canvas. Everything is ok. But when I scroll the TreeView down, the items that were outside visible part of the window are shown without that additionally drawn info (see picture 2 https://drive.google.com/open?id=149ks0-1WHnCMvXsIZfwoV1P8C3o7pdRV). It's the same on Lazarus 1.8.2 and 1.8.4, both Linux and Windows. Any ideas how to deal with it? P.S. As a temporary workaround I use "force" redraw by timer, but this has its own issues. ---------------------------------------------------------------------- jamie · 2018-10-29 16:29 You need to show us the code section in the Custom Draw event. Something tells me you maybe using the wrong canvas or rectangle etc.. ---------------------------------------------------------------------- DmytroLev · 2018-10-29 17:15 Here is the code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainForm.TreeViewRahunkyAdvancedCustomDrawItem(  Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState;  Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean);var    dlRightBorder:integer;    dlLeftBorder:integer;    dlTextOfNode,dlNomerRahunku:string;    dlCreateDate:TDateTime;    dlRect: TRect;begin   dlLeftBorder:=TreeViewRahunky.Left;   dlRightBorder:=TreeViewRahunky.Width;   dlTextOfNode:=Node.Text;   dlNomerRahunku:=dl_GetTextBeginning(dlTextOfNode,#9);//here I extract an ID to get additional data from DB   dlCreateDate:=SQLQueryRahTab.Lo okup('SRT_NOMER_SUBRAH',dlNomerRahunku,'SRT_DENPOYAVY');//Getting additional data (planned to add more in future, and show in several drawn "columns")   with TreeViewRahunky.Canvas do     begin      if node.Selected then begin       Brush.Style := bsSolid;       Brush.Color := clHighLight;       FillRect(rect(Node.DisplayTextLeft, Node.Top,dlRightBorder,Node.Bottom));       Brush.Style := bsClear;     TextOut(Node.DisplayTextLeft,Node.Top,Node.Text);      end      else begin       Brush.Style := bsSolid;       Brush.Color := clCream;       FillRect(rect(dlRightBorder-210,Node.Top,dlRightBorder- 90,Node.Bottom));       Brush.Style := bsClear;      end;      TextOut (dlRightBorder- 200,Node.Top+1,FormatDateTime('dd.mm.yyyy',dlCreateDate));    end;end; ---------------------------------------------------------------------- jamie · 2018-10-29 23:30 Try using  Node.DisplayRect(True/False ?) for the actual Canvas rectangle area. This reports the actual location you need to be, from there you can calculate, It think the parameters you are using are based from a non scrolled windows, because you can also query the ScrolledLeft and ScrollTop information.. The Display rectangle should return a TRECT with all the info in it. ---------------------------------------------------------------------- DmytroLev · 2018-10-30 05:33 Thanks a lot, jamie! Your advice helped, now I set the coordinates based on DisplayRect, and the additionally drawn info now doesn't disappear. Left and right coordinates where ok, I only had to get Top and Bottom from DisplayRect instead of Node.Top and Node.Bottom: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i dlRect:=Nod e.DisplayRect(true);{...}FillRect(rect(dlRightBorder- 210,dlRect.Top,dlRightBorder-90,dlRect.Bottom));