如何引导鼠标滚轮输入控制光标而不是聚焦? [英] How to direct the mouse wheel input to control under cursor instead of focused?
本文介绍了如何引导鼠标滚轮输入控制光标而不是聚焦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了一些滚动控件: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屋!
查看全文