如何将鼠标滚轮输入直接控制在光标下而不是聚焦? [英] How to direct the mouse wheel input to control under cursor instead of focused?

查看:25
本文介绍了如何将鼠标滚轮输入直接控制在光标下而不是聚焦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了许多滚动控件:TTreeViews、TListViews、DevExpress cxGrids 和 cxTreeLists 等.当鼠标滚轮旋转时,无论鼠标光标在哪个控件上,具有焦点的控件都会接收输入.

I use a number of scrolling controls: TTreeViews, TListViews, DevExpress cxGrids and cxTreeLists, etc. When the mouse wheel is spun, the control with focus receives the input no matter what control the mouse cursor is over.

您如何将鼠标滚轮输入定向到鼠标光标所在的任何控件?Delphi IDE 在这方面做得很好.

How do you direct the mouse wheel input to whatever control the mouse cursor is over? The Delphi IDE works very nicely in this regard.

推荐答案

尝试像这样覆盖表单的 MouseWheelHandler 方法(我没有彻底测试过):

Try overriding your form's MouseWheelHandler method like this (I have not tested this thoroughly):

procedure TMyForm.MouseWheelHandler(var Message: TMessage);
var
  Control: TControl;
begin
  Control := ControlAtPos(ScreenToClient(SmallPointToPoint(TWMMouseWheel(Message).Pos)), False, True, True);
  if Assigned(Control) and (Control <> ActiveControl) then
  begin
    Message.Result := Control.Perform(CM_MOUSEWHEEL, Message.WParam, Message.LParam);
    if Message.Result = 0 then
      Control.DefaultHandler(Message);
  end
  else
    inherited MouseWheelHandler(Message);

end;

这篇关于如何将鼠标滚轮输入直接控制在光标下而不是聚焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆