MaxPos := ScrInfo.nMax - Integer(ScrInfo.nPage) + 1;
case Msg.ScrollCode of
SB_LINEUP:
if ScrInfo.nPos > ScrInfo.nMin then
begin
Dec(ScrInfo.nPos);
end;
SB_LINEDOWN:
if ScrInfo.nPos < MaxPos then
begin
Inc(ScrInfo.nPos);
end;
SB_PAGEUP:
if ScrInfo.nPos > ScrInfo.nMin then
begin
Dec(ScrInfo.nPos, ScrInfo.nPage);
end;
SB_PAGEDOWN:
if ScrInfo.nPos < MaxPos then
begin
Inc(ScrInfo.nPos, ScrInfo.nPage);
end;
SB_THUMBPOSITION,
SB_THUMBTRACK:
begin
// ScrInfo.nPos := Msg.Pos;
// Msg.Pos是16-bits的, 行数太多时会溢出
ScrInfo.nPos := ScrInfo.nTrackPos;
end;
SB_LEFT:
if ScrInfo.nPos <> ScrInfo.nMin then
begin
ScrInfo.nPos := ScrInfo.nMin;
end;
SB_RIGHT:
if ScrInfo.nPos < MaxPos then
begin
ScrInfo.nPos := MaxPos;
end;
SB_ENDSCROLL:
begin
ScrInfo.nPos := ScrInfo.nPos;
end;
end;
if ScrInfo.nPos < ScrInfo.nMin then
ScrInfo.nPos := ScrInfo.nMin;
if ScrInfo.nPos > MaxPos then
ScrInfo.nPos := MaxPos;
UpdateScrollPos(AScrollKind, ScrInfo.nPos);
Result := ScrInfo.nPos;
end;
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The nPos parameter indicates the position that the scroll box has been dragged to.