Recent

Author Topic: TScrollBox ScrollBy Method Not Working  (Read 234 times)

andrew Bubble

  • Jr. Member
  • **
  • Posts: 59
TScrollBox ScrollBy Method Not Working
« on: November 07, 2025, 10:19:34 pm »
Hi All

I have a question concerning the ScrollBy method of TScrollBox.

I have a simple Form with a scrollBox Height set to 300 and inside the scrollBox a TPaintBox with height set to 1200.

I also have 12 lines text drawn on the TPaintbox starting from the top at 100 pixel intervals.

With the vertical scrollbar visible, I can move up and down within the ScrollBox as expected.

I also have two buttons on the form, one with ScrollBox1.ScrollBy(0, 100) and the other with ScrollBox1.ScrollBy(0, -100) in the OnClick methods

Pressing either buttons during runtime does not scroll either up or down.

I am using Lazarus 4.3 on a Raspberry PI with OS BookWorm, I also have an old version of Lazarus on my Windows 10 laptop and this also does not work.

However, I also have an old version of Delphi (7) and replicated the program and this worked exactly as expected, pressing either button moves up and down within the scrollbox.

As a final step, I saved the Delphi 7 program and used the Delphi Conversion tool in Lazarus to see if there was any difference and there was none.

Is there something I am missing using the ScrollBy method in Lazarus compared to how Delphi implements this.

Regards Andrew

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: TScrollBox ScrollBy Method Not Working
« Reply #1 on: November 07, 2025, 11:05:54 pm »
I can confirm your observation on Windows 11, but I can't say whether it is a bug or a consequence of the fact that the method must be compatible with all widgetsets.

But anyway, since the scrollbars are working you could modifiy the VertScrollBar.Position to achieve the scrolling; this is working at least for me:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Scrollbox1.VertScrollbar.Position := Scrollbox1.VertScrollbar.Position - 100;
  4. end;
  5.  
  6. procedure TForm1.Button2Click(Sender: TObject);
  7. begin
  8.   Scrollbox1.VertScrollbar.Position := Scrollbox1.VertScrollbar.Position + 100;
  9. end;

andrew Bubble

  • Jr. Member
  • **
  • Posts: 59
Re: TScrollBox ScrollBy Method Not Working
« Reply #2 on: November 07, 2025, 11:54:17 pm »
Hi Wp

Thanks for your response, I have tried this on my Windows PC and it works to a point, I notice that when the scrollbar visibility is set to false the increment and page are set to 1.

Anyway I have tried this on my Raspberry PI (Linux) and setting the ScrollBar positions has no effect when not visible.

Setting the position when the scrollbars are visible does work but defeats the object of having them not showing in the first place.

Regards Andrew

 

TinyPortal © 2005-2018