Die Holländer 33 Posted July 8 I started to display your test just in a THTML viewer. Nice, because you can continue to format the text with whatever you want (colors, fonts, etc) The wordwrap is very fast. Maybe you can even add an onClick in code to capture a click on one of the <div> procedure TForm1.BitBtn1Click(Sender: TObject); var idx: Integer; begin for idx := 1 to 10 do Begin HtmlViewer1.Text:=HtmlViewer1.Text+'<div>'+IntToStr(idx)+': '+setCaption+'</div><br>'; End; end; HtmlViewer 10.2 is still available at: http://code.google.com/p/thtmlviewer/ HtmlViewer 11.x is available at: https://sourceforge.net/projects/htmlviewer/ HtmlViewer development is hosted at: https://github.com/BerndGabriel/HtmlViewer 1 Share this post Link to post
#ifdef 12 Posted July 9 23 hours ago, Die Holländer said: I started to display your test just in a THTML viewer. Nice, because you can continue to format the text with whatever you want (colors, fonts, etc) The wordwrap is very fast. Maybe you can even add an onClick in code to capture a click on one of the <div> procedure TForm1.BitBtn1Click(Sender: TObject); var idx: Integer; begin for idx := 1 to 10 do Begin HtmlViewer1.Text:=HtmlViewer1.Text+'<div>'+IntToStr(idx)+': '+setCaption+'</div><br>'; End; end; HtmlViewer 10.2 is still available at: http://code.google.com/p/thtmlviewer/ HtmlViewer 11.x is available at: https://sourceforge.net/projects/htmlviewer/ HtmlViewer development is hosted at: https://github.com/BerndGabriel/HtmlViewer It looks really good, but on older computers 1000+ lines are too slow to render when resizing the canvas — and I can’t use pagination because the entire list must be available. But thanks anyway! Share this post Link to post
Die Holländer 33 Posted July 9 17 minutes ago, #ifdef said: It looks really good, but on older computers 1000+ lines are too slow to render when resizing the canvas — and I can’t use pagination because the entire list must be available. But thanks anyway! Are you sure? Did you tried it? The speed is in no way comparible with your TControlList example. The HTML renderer is very fast, also on older computers. Otherwise displaying a webpage on these computers is also not possible.. Share this post Link to post
#ifdef 12 Posted July 9 (edited) Yes, I'm sure THtmlViewer + 10000 (start is ~5 seconds, resize is slow): unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, System.Math, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, HTMLUn2, HtmlView; type TForm1 = class(TForm) HtmlViewer1: THtmlViewer; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function setCaption: string; var Lt: string; Li, Ll: integer; begin Ll := RandomRange(10, 1000); Lt := ''; for Li := 1 to Ll do begin if (Random(10) = 0) and (Li < Ll) then begin Lt := Lt + ' '; end else begin if Random(2) = 0 then Lt := Lt + Chr(RandomRange(65, 90)) else Lt := Lt + Chr(RandomRange(97, 122)); end; end; Result := Lt; end; procedure TForm1.FormCreate(Sender: TObject); var Li: integer; Ls: string; begin for Li := 1 to 10000 do Ls := Ls + '<div>' + Li.ToString + ': ' + setCaption + '</div><br>'; HtmlViewer1.Text := Ls; end; end. TControlList + 10000 (start is ~1 second, resize is ok): unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, System.Math, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ControlList; type TForm1 = class(TForm) ControlList1: TControlList; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas; ARect: TRect; AState: TOwnerDrawState); private { Private declarations } public { Public declarations } end; var Form1: TForm1; FList: TStringList; implementation {$R *.dfm} function setCaption: string; var Lt: string; Li, Ll: integer; begin Ll := RandomRange(10, 1000); Lt := ''; for Li := 1 to Ll do begin if (Random(10) = 0) and (Li < Ll) then begin Lt := Lt + ' '; end else begin if Random(2) = 0 then Lt := Lt + Chr(RandomRange(65, 90)) else Lt := Lt + Chr(RandomRange(97, 122)); end; end; Result := Lt; end; procedure TForm1.ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas; ARect: TRect; AState: TOwnerDrawState); begin Label1.Caption := FList[AIndex]; end; procedure TForm1.FormCreate(Sender: TObject); begin FList := TStringList.Create; ControlList1.ItemCount := 10000; for var Li := 0 to ControlList1.ItemCount - 1 do FList.Add(Li.ToString + ': ' + setCaption); end; end. Edited July 9 by #ifdef Share this post Link to post
#ifdef 12 Posted July 9 (edited) THtmlViewer: https://i.ibb.co.com/XXX8pt9/image.gif TControlList: https://i.ibb.co.com/84bg3g1/1.gif Edited July 9 by #ifdef Share this post Link to post
Die Holländer 33 Posted July 9 18 minutes ago, #ifdef said: ControlList + 10000 (start is ~1 second, resize is ok): Yes, but its only resizing/displaying a small part of the text height, while the HTML is showing the entire text.. I wonder what your user case is. Who is going to read that much text at once when you can't use pagination, etc.. Share this post Link to post
#ifdef 12 Posted July 9 2 hours ago, Die Holländer said: Yes, but its only resizing/displaying a small part of the text height, while the HTML is showing the entire text.. I wonder what your user case is. Who is going to read that much text at once when you can't use pagination, etc.. That's why I chose the TControlList — it allows to instantly move to any place, all that remains is to fix the fixed row height 🙂 Share this post Link to post
Alexander Sviridenkov 345 Posted July 9 HtPanel (DX canvas) https://drive.google.com/file/d/1Eig5hvn619Mz3ATh7lTl65Zh3TUN4Vey/view?usp=sharing 1 Share this post Link to post
Kas Ob. 109 Posted July 10 @#ifdef Well , while i hate my life nowadays, and while just waiting for the blackout to brighten my day after only 3 hours of power, i tried to build you something Far from finished or polished, take it as example or prototype for what you can do with custom drawing, notice it is 10000 strings ! ListBoxAsStringList.zip My suggestion is to use VirtualTreeView, i couldn't find working copy of VTV on my PC now, and don't want to waste time downloading my encrypted archives from the cloud, so i used TListBox, it is simple easy and pretty straight forward. Notes: 1) i didn't use FillRec on the whole Listbox, while it is more efficient and faster to clear the background for all the items in one go, this will introduce an ugly flicker in the bottom half, do the system rendering which doesn't wait for anyone, by clearing the background for each item in time, we prevent this flicker, but will introduce small performance hit in overall drawing. 2) i disabled the selected item highlighting, because it does need little different approach, yet it is easy, just adjust the canvas brush color before the FillRect, this will be up to you to implement, as i said i don't have time and don't have the skins on the latest IDE versions to test and play with. 3) customize as you wish, like ... can you this ? ( there is no noticeable performance change) Hope that helps, also never underestimate Windows custom drawing, it is fucking blazing fast when done right. 3 Share this post Link to post