小编Alh*_*mam的帖子

滚动框鼠标滚轮delphi

如何将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;
Run Code Online (Sandbox Code Playgroud)

delphi vcl

3
推荐指数
1
解决办法
8671
查看次数

标签 统计

delphi ×1

vcl ×1