RickyBelmont
RickyBelmont

Reputation: 639

How to Use the OnViewportPositionChange of TVertScrollBox

I am trying to figure out how to use the OnViewportPositionChange of TVertScrollBox for my visual component trigger when it reach to certain level. It appears to me that this event OnViewportPositionChange is useful for this purpose.

procedure TformMain.VertScrollBox1ViewportPositionChange(Sender: TObject;
  const OldViewportPosition, NewViewportPosition: TPointF;
  const ContentSizeChanged: Boolean);
begin
   ...
end;

How can I detect/determine if the NewViewportPosition meets the criteria (TPointF) to trigger if it is True a visual component to set as visible.

I will appreciate if someone could give a quick sample.

ATTEMPT 1: No response and I can't use the this operand type >=.

  if NewViewportPosition = PointF(VertScrollBox1.ViewportPosition.X, 720) then
  begin
    ShowMessage('Success!');
  end;

Upvotes: 0

Views: 241

Answers (1)

Freddie Bell
Freddie Bell

Reputation: 2287

TPointF has 2 properties you can use: .X and .Y. You can easily just examine the values individually for example:

if (NewViewPortPosition.X >= CurrPosition.X) or (NewViewPortPosition.Y >= CurrPosition.Y)

Upvotes: 1

Related Questions