Posts

Showing posts with the label delphi-10.2-tokyo

VertScrollBox Detect when bottom reached android and IOS

VertScrollBox Detect when bottom reached android and IOS I have GridLayout1 on a VertScrollBox1 . The vertical scroll box scrolls through the content of the grid layout. I need to detect when the Vertical scroll box reach the bottom so I get to load more content to the grid layout. And do it again whenever bottom is reached again. GridLayout1 VertScrollBox1 How can I achieve this? 1 Answer 1 Use the OnViewportPositionChange() of the VertScrollBox1 . Then some simple arithmetics tell you when you are at the bottom: OnViewportPositionChange() VertScrollBox1 uses Math, ...; // ... procedure TForm1.VertScrollBox1ViewportPositionChange(Sender: TObject; const OldViewportPosition, NewViewportPosition: TPointF; const ContentSizeChanged: Boolean); begin if CompareValue(NewViewportPosition.Y, GridLayout1.Height - VertScrollBox1.Height) = EqualsValue then Memo1.Lines.Add('At bottom, time to gro...

Delphi TThread handle error

Image
Delphi TThread handle error I am reading "Delphi High performance" and there is something that I am missing. Given this code as test: type TTest = class(TThread) private amemo: TMemo; public constructor Create(ss: boolean; memo: TMemo); protected procedure Execute; override; end; constructor TTest.Create(ss: boolean; memo: TMemo); begin inherited Create(ss); FreeOnTerminate := true; amemo := memo; end; procedure TTest.Execute; var i: uint32; begin inherited; i := 0; while not Terminated do begin Inc(i); Synchronize(procedure begin amemo.Lines.Add(i.ToString) end); Sleep(1000); end; end; Very simply, this thread prints some numbers in a memo. I start the thread suspended and so I have to call this piece of code: procedure TForm1.Button1Click(Sender: TObject); begin thread := TTest.Create(true, Memo1); thread.Start; end; I have always stopped the thread calling thread.Terminate; but reading the book ...