Delphi interface scroll bar is controlled by mouse scroll

1. Add control applicationevents

2. Add the following methods to the message event of this space

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;

  var Handled: Boolean);
begin
  //窗体的滚动条响应鼠标滚轮
  if Msg.message = WM_MOUSEWHEEL then
  begin
    if self.Visible then
    begin
      if Msg.wParam >0 then
      begin
        self.VertScrollBar.Position := self.VertScrollBar.Position - self.VertScrollBar.increment;
      end
      else
      begin
        self.VertScrollBar.Position := self.VertScrollBar.Position + self.VertScrollBar.increment;
      end;
      Handled := True;
    end
    else
      Handled := false;
  end;
end;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325494891&siteId=291194637