如果在按下Shift
键的同时使用鼠标滚轮,我想实现水平滚动。但在这种情况下,我没有收到任何WM_MOUSEWHEEL
条消息:
procedure WMMouseWheel(var Msg: TMessage); message WM_MOUSEWHEEL; // is not called
根据documentation,WM_MOUSEWHEEL
WPARAM应该有MK_SHIFT
条消息。
有什么想法吗?
答案 0 :(得分:5)
我在代码库中找到了这段代码:
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
来处理此消息。