The use of shift + scroll wheel is fairly common for horizontal scrolling.
Both of those are fairly easy to capture. I can use the MouseWheel event with a flag set by the KeyDown, KeyUp events to keep track of when the shift key is pressed.
However, how do I actually trigger the horizontal scrolling? I am aware of WM_MOUSEHWHEEL, can that be used to trigger the event?
Update:
For a System.Windows.Form there is a HorizontalScroll property that is of type HScrollProperties. You can manipulate the Value attribute on that object to change the horizontal scrollbar’s position. However, so far I haven’t spotted any other controls on which that object is available.
If you are creating your own control derived from
UserControlorScrollControlorForm, you can use this simple solution:Explanation
If a control has
AutoScrolland is displaying scrollbars, when you scroll the mouse wheel you will get the following behaviour:Noticing this behaviour, I figured out this hack to override
OnMouseWheelof the control, then if the vertical scrollbar is enabled and Shift is held down, it disables the vertical scrollbar before callingbase.OnMouseWheel. This will trick the control in scrolling the horizontal scrollbar (behaviour 3 as shown above).