本文整理自网络,侵删。
//方法1:procedure TForm1.ScrollBoxMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);var LTopLeft, LTopRight, LBottomLeft, LBottomRight: SmallInt; LPoint: TPoint; ScrollBox: TScrollBox;begin ScrollBox := TScrollBox(Sender); LPoint := ScrollBox.ClientToScreen(Point(0,0)); LTopLeft := LPoint.X; LTopRight := LTopLeft + ScrollBox.ClientWidth; LBottomLeft := LPoint.Y; LBottomRight := LBottomLeft + ScrollBox.ClientWidth; if (MousePos.X >= LTopLeft) and (MousePos.X <= LTopRight) and (MousePos.Y >= LBottomLeft) and (MousePos.Y <= LBottomRight) then begin ScrollBox.VertScrollBar.Position := ScrollBox.VertScrollBar.Position - WheelDelta; Handled := True; end;end;
//方法2:procedure TForm1.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);begin Handled := True; if WheelDelta < 0 then TScrollBox(Sender).VertScrollBar.Position := TScrollBox(Sender).VertScrollBar.Position + TScrollBox(Sender).VertScrollBar.Increment else TScrollBox(Sender).VertScrollBar.Position := TScrollBox(Sender).VertScrollBar.Position - TScrollBox(Sender).VertScrollBar.Increment;end;
相关阅读 >>
Delphi 的webbrowser如何全选并复制浏览器上的文字
Delphi tstringlist 保存txt文本文件最后一行不留空行
Delphi研究之驱动开发篇(六)--利用section与用户模式程
Delphi 将 4 个 byte 合成 1 个 integer 的五种方法 - 回复 "三足乌" 的问题
更多相关阅读请进入《Delphi》频道 >>