View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0037673||Lazarus||-||public||2020-08-31 22:34||2021-04-14 03:35|
|Reporter||Russell Crosser||Assigned To|
|Summary||0037673: Unreliable scroll of memo using vertscrollbar.position|
|Description||Bug in Memo scrolling.|
HP Laptop 15-bw0xx,
Windows 10, Lazarus 2.06, 2020-04-24
FPC 3.0.4 SVN Revision 62129
Problem: I am trying to scroll a memo accurately to a highlighted line by setting Memo1.VertScrollBar.Position = desired line number.
It generally works, but if I use the mouse scrollwheel to change the view, the positioning is no longer accurate, and the
highlighted text may be outside the visible area. This remains so through some further searches. The system corrects if
I manually scroll the vertical scrollbar to zero.
It works reliably if I use
SendMessage(Memo1.Handle, EM_LINESCROLL, 0, n - Memo1.VertScrollBar.Position)
A similar problem was reported in Lazarus forum:
Setting TMemo.VertScrollBar.Position does not scroll the text field
« on: November 22, 2015, 02:36:56 am »
That was where I got the workaround. It doesn't seem to be fixed, or it is a slightly different bug.
Russell Crosser firstname.lastname@example.org
|Steps To Reproduce||Set Memo1.VertScrollBar.Position to a chosen line beyond the last visible line. the memo scrolls to it. Use the mouse |
scroll wheel to change the view downward (text going up), even by only 1 line. Set Memo1.VertScrollBar.Position to 0.
Memo scrolls to a low number, but the first line is not visible, along with zero to a few more lines. It remains inaccurate
through a few or many further iterations, but corrects itself if I scroll to the top with the vertical scrollbar.
Works fine if I don't use the wheel.
|Additional Information||See sample program and screen dump.|
|Tags||No tags attached.|
|Fixed in Revision|
MemoScroll.zip (129,750 bytes)
To work this correctly, you need:
1. Synchronize the internal state of the position with the actual state, since it is cached. To do this, just call any read method, such as Memo1.VertScrollBar.GetPosition (without assignment!), before starting the changes.
2. Set cursor position first: Memo1.CaretPos := ...; Memo1.SetFocus;
3. Set scroll position: Memo1.VertScrollBar.Position := n;
Memo1.CaretPos := Point(0, i);
Memo1.SelLength := 6;
Memo1.VertScrollBar.Position := n;
||Thank you, I will try this.|
|2020-08-31 22:34||Russell Crosser||New Issue|
|2020-08-31 22:34||Russell Crosser||File Added: MemoScroll.zip|
|2020-08-31 22:34||Russell Crosser||File Added: MemoScroll.png|
|2020-08-31 22:48||Jonas Maebe||Project||FPC => Lazarus|
|2020-09-01 17:39||Serge Anvarov||Note Added: 0125282|
|2020-09-01 17:40||Serge Anvarov||Note Edited: 0125282||View Revisions|
|2021-04-14 03:35||Russell Crosser||Note Added: 0130363|