jpf*_*ius 2 delphi delphi-10.1-berlin
如果在Shift按下键的同时使用鼠标滚轮,我想实现水平滚动.但WM_MOUSEWHEEL在这种情况下我没有收到任何消息:
procedure WMMouseWheel(var Msg: TMessage); message WM_MOUSEWHEEL; // is not called
Run Code Online (Sandbox Code Playgroud)
根据文档,WPARAM 应该有一条WM_MOUSEWHEEL消息MK_SHIFT.
有任何想法吗?
我在代码库中找到了这段代码:
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;
Run Code Online (Sandbox Code Playgroud)
所以你有它.我不明白为什么会这样,但你应该能像我一样做,并覆盖WndProc来处理这个消息.
| 归档时间: |
|
| 查看次数: |
415 次 |
| 最近记录: |