1

I use the code

procedure TMyCanvas.RichEditChange(Sender: TObject);
var
  ScrollInfo: TScrollInfo;
begin

  FillChar(ScrollInfo, SizeOF(ScrollInfo), 0);
  ScrollInfo.cbSize := SizeOf(ScrollInfo);
  ScrollInfo.fMask := SIF_RANGE or SIF_PAGE or SIF_POS;
  if GetScrollInfo(FRichEdit.Handle, SB_VERT, ScrollInfo) then
  begin
    FVertScroll.Max := ScrollInfo.nMax;
    FVertScroll.Min := ScrollInfo.nMin;
    FVertScroll.PageSize := ScrollInfo.nPage;
    FVertScroll.Position := ScrollInfo.nPos;
  end;
  Invalidate;
end;

the problem is that when i add/remove lines it gives me error sometimes when im going to resize the form. it says "scrollbar property out of range"

how can i avoid it?

thanx

XBasic3000
  • 3,418
  • 5
  • 46
  • 91

2 Answers2

3

You could try setting the PageSize property, and calling SetParams to avoid setting individual properties one by one.

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
0

I was getting this error message and found that a change had been made when initialising the scrollbar whereby TScrollbar.Max was being set to 0 when PageSize was 2. Setting PageSize to 0 before Max to 0 fixed the issue.