How to draw text in TListView.onCustomDrawSubItem lazarus / 31-LCL ---------------------------------------------------------------------- zamtmn · 2012-10-23 09:51 I'm currently using Code: [Select]DefaultDraw:=false; textrect:=Item.DisplayRectSubItem(SubItem,drLabel); DrawText(TCustomListView(sender).canvas.Handle,@s[1],length(s),textrec t,DT_LEFT or DT_VCENTER); The text appears a few pixels above. How to make the text on the level with the defaultdraw items? ---------------------------------------------------------------------- howardpc · 2012-10-23 10:19 try DT_LEFT or DT_BOTTOM as the last parameter? ---------------------------------------------------------------------- zamtmn · 2012-10-23 10:23 Without result, looks the same ---------------------------------------------------------------------- howardpc · 2012-10-23 10:34 Perhaps you'll just have to hack, and adjust textrect a few pixels manually with InflateRect or similar. ---------------------------------------------------------------------- zamtmn · 2012-10-23 10:42 But I would like the decision to work on all platforms and themes ---------------------------------------------------------------------- Ocye · 2012-10-24 11:23 Maybe you calculate the rectangle too small. Test with Canvas.Rectangle, or the like. If so, DrawText has an option to measure boundaries: DT_CALCRECT. And perhaps you could check functions in unit themes as well. ---------------------------------------------------------------------- zamtmn · 2012-10-24 12:40 No, rectangle is good. QuoteDrawText(TCustomListView(sender).canvas.Handle,@s[1],length(s),te xtrect,DT_LEFT or DT_SINGLELINE or DT_VCENTER);or Code: [Select]ts:=TCustomListView(Sender).Canvas.TextStyle; ts.Layout:=tlCenter; TCustomListView(sender).canvas.TextRect(textrect,textrect.Left,0,s,ts) ;looks good in win32, but text much lower in gtk2 >>And perhaps you could check functions in unit themes as well. Thanks, I will look