我在代碼庫中找到這段代碼:
procedure TMyScrollBox.WndProc(var Message: TMessage);
begin
if Message.Msg=WM_MOUSEHWHEEL then begin
(* For some reason using a message handler for WM_MOUSEHWHEEL doesn't work.
The messages don't always arrive. It seems to occur when both scroll bars
are active. Strangely, if we handle the message here, then the messages
all get through. Go figure! *)
if TWMMouseWheel(Message).Keys=0 then begin
HorzScrollBar.Position := HorzScrollBar.Position + TWMMouseWheel(Message).WheelDelta;
Message.Result := 0;
end else begin
Message.Result := 1;
end;
end else begin
inherited;
end;
end;
所以,你有它。我不明白爲什麼會出現這種情況,但您應該可以像我這樣做,並覆蓋WndProc
來處理此消息。
有很多信息:[如何指導鼠標滾輪輸入控制光標而不是聚焦?](https://stackoverflow.com/a/34386680/757830)和[如何添加鼠標滾輪是否支持TGraphicControl後續組件?](https://stackoverflow.com/a/34463279/757830)。 – NGLN