How to determine if the scrollbar is at the very bottom?

It is easy to determine if the vertical scrollbar is TScrollBoxat the very top or not:

IsScrollBarAtTop := ScrollBox1.VertScrollBar.Position = 0;

enter image description here

But how can I determine if the vertical scrollbar is TScrollBoxin the BOTTOM itself or not?

enter image description here

+4
source share
2 answers

You can get the scroll bar information through the API and determine if it is at the bottom.

function IsScrollBarAtBottom(Box: TScrollBox): Boolean;
var
  Info: TScrollInfo;
begin
  Info.cbSize := SizeOf(Info);
  Info.fMask := SIF_POS or SIF_RANGE or SIF_PAGE;
  Win32Check(GetScrollInfo(Box.Handle, SB_VERT, Info));
  Result := Info.nPos >=  Info.nMax - Info.nMin - Info.nPage;
end;
+8
source

From Vcl.Forms.TControlScrollBar.Range :

( ) . , 500, 200, 0 300.

IsScrollBarAtBottom :=  ScrollBox1.VertScrollBar.Position =
  (ScrollBox1.VertScrollBar.Range - ScrollBox1.ClientHeight);

, .

+5

Source: https://habr.com/ru/post/1662819/


All Articles