我需要在一个对话框(MFC)上捕捉中键事件,比如中键往下滑动,往上滑动。应该怎么实现呢?请高手帮帮我啊!

解决方案 »

  1.   

    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 
    );
      

  2.   

    CWnd::OnMouseWheel
    afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );Return ValueNonzero if mouse wheel scrolling is enabled; otherwise 0.ParametersnFlagsIndicates 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. 
    zDeltaIndicates 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 Res for more information about this parameter.ptSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.ResThe 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.
      

  3.   

    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.