开发者

How to prevent the Scrollbar out of range?

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜