Recent

Author Topic: Retaining the scrollbars position  (Read 205 times)

Ed78z

  • New Member
  • *
  • Posts: 35
Retaining the scrollbars position
« on: October 08, 2024, 01:15:26 am »
Is this a bug or not?:

I'm saving position of the scrollbars and then trying to restore them to get back to the previous location(view) in a TMemo....

Code: Pascal  [Select][+][-]
  1. Var
  2.    M:TPoint;
  3. begin
  4.   Form1.Memo1.ScrollBars:=ssAutoBoth;
  5.   M.X:=Form1.Memo1.HorzScrollBar.Position;
  6.   M.Y:=Form1.Memo1.VertScrollBar.Position;
  7.    .....
  8.    ..... // some changes in the Memo1's contents
  9.    .....
  10.   Form1.Memo1.HorzScrollBar.Position:=M.X;
  11.   Form1.Memo1.VertScrollBar.Position:=M.Y;
  12. end;
  13.  


If M.X was 15, then at the end the HorzScrollBar.Position will be 15-1=14. Same for M.Y and VertScrollBar.Position, if M.Y=27, then the value will be 27-1=26. I can't set them to initial values, even with M.X+1

Is this a bug?

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: Retaining the scrollbars position
« Reply #1 on: October 08, 2024, 01:40:37 am »
OS/Widget?

the scrollbars need to be enabled btw.
The only true wisdom is knowing you know nothing

Ed78z

  • New Member
  • *
  • Posts: 35
Re: Retaining the scrollbars position
« Reply #2 on: October 08, 2024, 04:25:27 am »
Windows 11 x64
Lazarus 3.6

The scrollbars are part of TMemo (Form1.Memo1.ScrollBars:=ssAutoBoth)

 

TinyPortal © 2005-2018