如何将鼠标滚轮支持添加到TGraphicControl下的组件? [英] How to add mouse wheel support to a component descended from TGraphicControl?

查看:226
本文介绍了如何将鼠标滚轮支持添加到TGraphicControl下的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个从TGraphicControl下载的delphi组件。是否可以添加对鼠标滚轮的支持?



---编辑---



我已经暴露了MouseWheel事件,如下所示,但它们不被调用。

  TMyComponent = class(TGraphicControl)
已发布
属性OnMouseWheel;
属性OnMouseWheelDown;
属性OnMouseWheelUp;
结束

---编辑---



如下所示,我试图捕获WM_MOUSEWHEEL和CM_MOUSEWHEEL消息,但它似乎不起作用。但是,我设法捕获CM_MOUSEENTER消息。我不明白为什么我可以捕获一种类型的消息,而不是其他消息。

解决方案

TGraphicControl TControl ,它已经具有鼠标滚轮支持。请参阅 wm_MouseWheel 消息, DoMouseWheel DoMouseWheelDown DoMouseWheelUp MouseWheelHandler 方法,以及 WheelAccumulator 属性。 / p>

I have created a delphi component which descends from TGraphicControl. Is it possible to add support for mouse wheels?

--- Edit ---

I've exposed the MouseWheel events as shown below but they aren't called.

TMyComponent = class(TGraphicControl)
published
  property OnMouseWheel;
  property OnMouseWheelDown;
  property OnMouseWheelUp;
end;

--- Edit ---

As suggested below, I've tried to trap the WM_MOUSEWHEEL and CM_MOUSEWHEEL messages, but it doesn't seem to work. However I've managed to trap the CM_MOUSEENTER message. I don't understand why i can trap one type of message, but not the other.

解决方案

TGraphicControl descends from TControl, which already has mouse-wheel support. See the wm_MouseWheel message, the DoMouseWheel, DoMouseWheelDown, DoMouseWheelUp, and MouseWheelHandler methods, and the WheelAccumulator property.

这篇关于如何将鼠标滚轮支持添加到TGraphicControl下的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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