Question

There is no horizontal scroll when I call this method in Delphi 3 under Windows 7:

const MOUSEEVENTF_HWHEEL = $1000;
mouse_event(MOUSEEVENTF_HWHEEL, 0, 0, 120, 0);

Vertical scroll with MOUSEEVENTF_WHEEL works well. Result is same with SendInput, and return value indicates a success. My current mouse supports horizontal tilt, but has no horizontal scroller.

What is needed to use MOUSEEVENTF_HWHEEL?

SDK documentation: http://bit.ly/mouse_event

Mouse Hook

I created a second 32 bit exe program under Windows 7 only to see if the mouse sends messages when the horizontal wheel is scrolled. This hook receives VSCROLL but no HSCROLL messages.

MouseHook := SetWindowsHookEx(WH_MOUSE_LL, @MouseProc, hInstance, 0);
Was it helpful?

Solution

int main()
{
    Sleep(20000); // enough time to switch windows and position the mouse pointer
    mouse_event(MOUSEEVENTF_HWHEEL, 0, 0, 120, 0);
    return 0;
}

scrolled my selected firefox page to the right. the window had to be selected and the mouse pointer had to be over the page. i did that with the mouse enabled. Or also turned the mouse off while testing (using the on/off switch on the mouse itself), the result was the same. My mouse has a horizontal tilt as well, no scroller. (windows 7 ultimate)

EDIT

One thing to note: The program itself needs to handle the message. Firefox for example does. It shows the same behaviour as tilting the mouse wheel: the page scrolls left/right accordingly. Other programs, like IE, seem not to handle this message, so no scrolling at all. Even using the mouse (Logitech Performance MX without any addional software package) nothing scrolls. So, it seems there is no 100% solution to this problem by just sending the mouse_event messages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top