【发布时间】:2018-10-31 14:18:22
【问题描述】:
如何将OnMouseWheel 添加到两个滚动框的同一个表单中?我将方法应用到ScrollBox1,但我不知道如何将方法添加到ScrollBox2
procedure TForm3.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
LTopLeft, LTopRight, LBottomLeft, LBottomRight: SmallInt;
LPoint: TPoint;
begin
inherited;
LPoint := ScrollBox1.ClientToScreen(Point(0,0));
LTopLeft := LPoint.X;
LTopRight := LTopLeft + ScrollBox1.Width;
LBottomLeft := LPoint.Y;
LBottomRight := LBottomLeft + ScrollBox1.Width;
if (MousePos.X >= LTopLeft) and
(MousePos.X <= LTopRight) and
(MousePos.Y >= LBottomLeft)and
(MousePos.Y <= LBottomRight) then
begin
ScrollBox1.VertScrollBar.Position :=
ScrollBox1.VertScrollBar.Position - WheelDelta;
Handled := True;
end;
end;
【问题讨论】: