-
September 15th, 2010, 10:04 AM
#1
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
-
September 16th, 2010, 04:05 AM
#2
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).
-
September 16th, 2010, 04:33 AM
#3
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
-
September 16th, 2010, 06:49 AM
#4
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).
-
September 16th, 2010, 07:25 AM
#5
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by Ralf Schneider
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).
-
September 16th, 2010, 07:29 AM
#6
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by ovidiucucu
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.
-
September 16th, 2010, 08:08 AM
#7
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
-
September 16th, 2010, 10:22 AM
#8
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by Ralf Schneider
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
Does it crash when you simply return 0 as well?
To call a handler from a handler normally isn't so good an idea cause each handler function available might return 0 (== not handled) what causes the dispatcher to search for another handler in the chain of windows. When you call CTrackView::OnMouseWheel you actually break that kind of logic. So, you better send a WM_MOUSEWHEEL message and before set the 'Shift Key' to be pressed by calling SetKeyboardState. Probably you also have to send a WM_KEYDOWN message before. After that you can return with 1 (== handled) cause now the normal handling of the vertical mouse wheel handling should happen and if you were lucky it should recognize the SHIFT key is being pressed.
-
September 16th, 2010, 10:27 AM
#9
Re: Horizontal scroll with OnMouseWheel ?
yes, it will also crash if I return 0.
But I will try your other suggestion as well.
thx.
Ralf
-
September 16th, 2010, 10:28 AM
#10
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by Ralf Schneider
But the app crashes. Has someone an idea why?
Did you change (or set) the _WIN32_WINNT macro to 0x0600 ? If yes, did you make a full rebuild after that? And didn't you use dlls where the _WIN32_WINNT macro was set differently?
The problem is that by setting the macro WINAPI header files and some structures would change in size. If you have mixed code or even use old precompiled headers the crash can be because of that.
-
September 16th, 2010, 10:35 AM
#11
Re: Horizontal scroll with OnMouseWheel ?
I have not used this macro.
-
September 16th, 2010, 10:46 AM
#12
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by Ralf Schneider
I have not used this macro.
And what compiler are you using? Is the WM_MOUSEHWHEEL defined in your headers?
-
September 16th, 2010, 10:53 AM
#13
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by Ralf Schneider
yes, it will also crash if I return 0.
But I will try your other suggestion as well.
thx.
Ralf
That probably means that you need to set the _WIN32_WINNT macro to 0x0600 (or higher) cause Windows couldn't handle the message (you might find an entry in the eventvwr).
Simply set it in the preprocessor definitions of your project by
_WIN32_WINNT=0x0600
separated by comma , from rthe other macros. Then rebuild all.
-
September 16th, 2010, 11:06 AM
#14
Re: Horizontal scroll with OnMouseWheel ?
Originally Posted by itsmeandnobodyelse
That probably means that you need to set the _WIN32_WINNT macro to 0x0600 (or higher) cause Windows couldn't handle the message (you might find an entry in the eventvwr).
Simply set it in the preprocessor definitions of your project by
_WIN32_WINNT=0x0600
separated by comma , from rthe other macros. Then rebuild all.
the mouse driver sends the WM_MOUSEHWHEEL message.
The according function will also be called.
I thought, in this case I do not need to set the macro?
Ralf
-
September 16th, 2010, 12:06 PM
#15
Re: Horizontal scroll with OnMouseWheel ?
Hello,
again a question about setting
_WIN32_WINNT macro to 0x0600
What do that really mean?
Do that mean that my app can only run on Windows vista and higher?
Ralf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|