Page 1 of 1

ScaleRichView page scrolling

Posted: Thu Jun 11, 2020 8:46 am
by DXS
Hi Sergey (or proxy)

We use ScaleRV as a viewer (readonly & hidden caret), however WMPageScroll still attempts to reposition the caret somewhere appropriate, which is unnecessary when not being used, and can lead to list index out of bounds errors, especially when a table is involved.

I did put in a hack that avoids the issue by doing a simple scroll and exit:

begin
CurRVData := RichViewEdit.TopLevelEditor.RVData;
CurItemNo := RichViewEdit.TopLevelEditor.CurItemNo;
CurItemOffs := RichViewEdit.TopLevelEditor.OffsetInCurItem;
Key := Message.wParam;
DeltaY := round(ClientHeight * PAGESCROLLPERCENT / FViewProperty.ZoomPercent);
if (Key = VK_PRIOR) then
DeltaY := -DeltaY;

// [JT] - don't need to reposition the caret if hidden (avoid list index out of bounds errors)
if not CaretVisible then
begin
//SetVScrollPos(DeltaY);
if (Key = VK_PRIOR) then
SetVScrollPos(GetVScrollPos - (ClientHeight div RichViewEdit.VSmallStep))
else
SetVScrollPos(GetVScrollPos + (ClientHeight div RichViewEdit.VSmallStep));
Exit;
end;

LCaretPos := FRVCaretRect.BottomRight;

But it would be better if something similar is done in a future version :mrgreen: