I am trying to write a program that scrolls the Internet Explorer's window upwards and downwards. I have almost what I need with the following line of code:

---------------------------------------------------------------------------
SendMessage(h, WM_VSCROLL, MAKEWPARAM(SB_LINEUP,0), 0);
----------------------------------------------------------------------------

However this scrolls a bit too fast. I am looking for smooth and gradual scrolling as if the scroll bar was dragged slowly.

I have tried replacing SB_LINEUP with SB_THUMBTRACK or SB_TRACKPOSITION and am able to get fine-grained control with this. The only problem is I cannot figure out how to determine the start position value (for the high part of WPARAM) so I cannot do a relative scroll from where the scroll bar currently is.

I tried using GetScrollInfo() as follows:

----------------------------------------------------------
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_TRACKPOS | SIF_RANGE | SIF_POS;
res = GetScrollInfo(h, SB_CTL, &si);
----------------------------------------------------------

I get res = 1 but the values in si look incorrect:

min = 29104704, max = 29102632, pos = 127, nTrackPos = 19, res = 1, le = 183

These do not change when I scroll the window (manually or with the above code), and if I remove the fmask=... line I get the same values, so these are definately invalid.

GetScrollPos() returns pos = 0 and GetLastError() returns 0 the first time, and 183 all the other times (I think this value is being set by another function and is meaningless).

I looked at the IE window with SPY++ and there doesn't seem to be a scroll bar control (separate window containg the scroll bar). This may be why the functions don't work.

Does anyone know of a way to get the vertical scroll bar position on IE? I will eventually use this on other programs so a general solution would be good, though a hack that only works for IE is also ok at this point.