防止鼠标滚轮滚动控件 [英] Preventing Mouse-wheel scrolling of controls

查看:111
本文介绍了防止鼠标滚轮滚动控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MFC库开发应用程序,并且当前正在尝试防止用户在滚动鼠标滚轮时意外更改其中一个组合框控件.

I am developing an application using the MFC library and I am currently trying to prevent the user accidentally changing one of the combo box controls when they are scrolling the mouse wheel.

我正在寻找一种解决方案,而不必从CComboBox类派生新类并防止鼠标滚动到那里.

I am looking for a solution without deriving a new class from the CComboBox class and preventing the mouse scrolling there.

我对系统的理解是Windows将WM_MOUSEWHEEL消息传递给处理它的组合框控件(滚动组合框),然后将其沿父控件链传播(因此将它们传播到我的CFormView等等),这意味着我无法通过在表单视图中捕获事件来阻止滚动.

My understanding of the system is that Windows passes the WM_MOUSEWHEEL message to the Combo box control which handles it (scrolling the combo box) and then this is propagated up the chain of parent controls (so them to my CFormView etc.), which means I cannot prevent the scrolling by capturing the event in my form view.

有人可以解决这个问题吗?预先感谢!

Does anyone have a solution to this problem? Thanks in advance!

推荐答案

在主窗口类中重写PreTranslateMessage处理程序,然后查找WM_MOUSEWHEEL消息.将PreTranslateMessage处理程序中的pMsg-> hwnd处理与组合框处理进行比较,如果找到,则将消息过滤掉.

Override the PreTranslateMessage handler in the main window class and look for WM_MOUSEWHEEL messages. Compare the pMsg->hwnd handle in PreTranslateMessage handler with the combobox handle, if found, filter the messages away.

这篇关于防止鼠标滚轮滚动控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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