怎样捕捉中键事件?

supergyc 2005-07-06 11:22:27
我需要在一个对话框(MFC)上捕捉中键事件,比如中键往下滑动,往上滑动。应该怎么实现呢?请高手帮帮我啊!
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangbaiou 2005-07-06
  • 打赏
  • 举报
回复
WM_MOUSEWHEEL
然后有前后两个值,可以判断是做什么
MK_CONTROL
The CTRL key is down.
MK_LBUTTON
The left mouse button is down.
MK_MBUTTON
The middle mouse button is down.
MK_RBUTTON
The right mouse button is down.
MK_SHIFT
The SHIFT key is down.
MK_XBUTTON1
Windows 2000/XP: The first X button is down.
MK_XBUTTON2
Windows 2000/XP: The second X button is down.
wuchi 2005-07-06
  • 打赏
  • 举报
回复
WM_MOUSEWHEEL
hiiiiiijiang 2005-07-06
  • 打赏
  • 举报
回复
CWnd::OnMouseWheel
afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );

Return Value

Nonzero if mouse wheel scrolling is enabled; otherwise 0.

Parameters

nFlags

Indicates whether various virtual keys are down. This parameter can be any combination of the following values:

MK_CONTROL Set if the CTRL key is down.


MK_LBUTTON Set if the left mouse button is down.


MK_MBUTTON Set if the middle mouse button is down.


MK_RBUTTON Set if the right mouse button is down.


MK_SHIFT Set if the SHIFT key is down.
zDelta

Indicates distance rotated. The zDelta value is expressed in multiples or divisions of WHEEL_DELTA, which is 120. A value less than zero indicates rotating back (toward the user) while a value greater than zero indicates rotating forward (away from the user). The user can reverse this response by changing the Wheel setting in the mouse software. See the Remarks for more information about this parameter.

pt

Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.

Remarks

The framework calls this member function as a user rotates the mouse wheel and encounters the wheel's next notch. Unless overridden, OnMouseWheel calls the default ofWM_MOUSEWHEEL. Windows automatically routes the message to the control or child window that has the focus. The Win32 functionDefWindowProc propagates the message up the parent chain to the window that processes it.

The zDelta parameter is a multiple of WHEEL_DELTA, which is set at 120. This value is the threshold for an action to be taken, and one such action (for example, scrolling forward one notch) should occur for each delta.

The delta was set to 120 to allow for future finer-resolution wheels, such as a freely-rotating wheel with no notches. Such a device might send more messages per rotation, but with a smaller value in each message. To support this possibility, either aggregate the incoming delta values until WHEEL_DELTA is reached (so you get the same response for a given delta-rotation), or scroll partial lines in response to the more frequent messages. You could also choose your scroll granularity and accumulate deltas until WHEEL_DELTA is reached.

Override this member function to provide your own mouse-wheel scrolling behavior.

Note OnMouseWheel handles messages for Windows NT 4.0. For Windows 95 or Windows NT 3.51 message handling, use OnRegisteredMouseWheel.

hiiiiiijiang 2005-07-06
  • 打赏
  • 举报
回复
WM_MOUSEWHEEL事件
CWnd::OnRegisteredMouseWheelSee Also
CWnd Overview | Class Members | Hierarchy Chart | RegisterWindowMessage
The framework calls this member function as a user rotates the mouse wheel and encounters the wheel's next notch.

afx_msg LRESULT OnRegisteredMouseWheel(
WPARAM wParam,
LPARAM lParam
);

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧