CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 18

Hybrid View

  1. #1
    Join Date
    Jul 2001
    Posts
    306

    Horizontal scroll with OnMouseWheel ?

    Hello,

    some special mouses have the ability to scroll also horizontal.
    What message is sent in this case?
    Can I use OnMouseWheel to handle this?
    (I have noch such a mouse)

    thx.

    Ralf

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Horizontal scroll with OnMouseWheel ?

    An horizontal scroll can already be realized with an ordinary mouse. You simply use the wheel and press the shift key at the same time.

    You can test that behaviour with a modern internet browser, e.g. Chrome, and http://codeguru/forum/ . Resize the window in order to see the horizontal scrollbar. Then, press the shilft key and roll the wheel of your mouse. You can see an horizontal scroll.

    I don't have a mouse with a special wheel for an horizontal scrolling, but I am pretty sure it works by simulating a pressure on the shift key and a motion of the wheel. In your program you would watch the WM_MOUSEWHEEL message (or onMouseWheel if you program with MFC) and watch the state of the shift key with GetKeyState(VK_SHIFT).

  3. #3
    Join Date
    Jul 2001
    Posts
    306

    Re: Horizontal scroll with OnMouseWheel ?

    Hello,

    I know about the behaviour with the shift key.
    It works in my app.
    But a user with a special mouse for horizontal scrolling says, that it do not.

    He can do it with shift and vert. scroll. But not with his horizontal scroll buttons.

    thx.
    Ralf

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Horizontal scroll with OnMouseWheel ?

    Handle WM_MOUSEHWHEEL message as well.
    Note that requires at least Windows Vista and Windows Server 2008 (_WIN32_WINNT >= 0x0600).
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #5
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Horizontal scroll with OnMouseWheel ?

    Quote Originally Posted by ovidiucucu View Post
    Handle WM_MOUSEHWHEEL message as well.
    Note that requires at least Windows Vista and Windows Server 2008 (_WIN32_WINNT >= 0x0600).
    You can try to setting _WIN32_WINNT=0x0600 in your preprocessor settings. If the mouse driver sends the WM_MOUSEWHEEL message you probably can handle the message even if not officially supported by the OS version.

  6. #6
    Join Date
    Jul 2001
    Posts
    306

    Re: Horizontal scroll with OnMouseWheel ?

    Hello,

    my customer uses Windows 7.
    My app has an implementation for horizontal scrolling with shift+mouse wheel.

    Then I implemented the horizontal wheel with this:

    Code:
    BOOL CTrackView::OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt) 
    {
    	return OnMouseWheel(nFlags | MK_SHIFT,zDelta,pt);
    }
    But the app crashes.
    Has someone an idea why?

    Ralf

  7. #7
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Horizontal scroll with OnMouseWheel ?

    Quote Originally Posted by Ralf Schneider View Post
    Hello,

    I know about the behaviour with the shift key.
    It works in my app.
    But a user with a special mouse for horizontal scrolling says, that it do not.

    He can do it with shift and vert. scroll. But not with his horizontal scroll buttons.

    thx.
    Ralf
    In XP he needs a special mouse driver for that device which should generate the needed messages, i. e. WM_MOUSEWHEEL, WM_KEYDOWN (of shift key) and setting the keyboard state (shift was pressed).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured