下载了一个控件的源代码,注释很少
有些地方没有完全看懂,请帮忙看看
//处理滚动条消息
//返回: 滚动条的Position
function
TCustomHexEdit.DoScroll(
AScrollKind: TScrollKind; Msg: TWMScroll): Integer;
var
BarFlag: Integer;
MaxPos: Integer;
ScrInfo: TScrollInfo;
begin
if AScrollKind = skHorizontal then
BarFlag := SB_HORZ
else
BarFlag := SB_VERT;
FillChar(ScrInfo, SizeOf(ScrInfo), 0);
ScrInfo.cbSize := SizeOf(ScrInfo);
ScrInfo.fMask := SIF_ALL;
GetScrollInfo(Handle, BarFlag, ScrInfo);
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;
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课