0
votes

I have HWND of external app window. From my App I need send message (or post) to scroll window on 100px down, I mean scroll offset must be 100px.

How can be done that? I try send WN_VSCROLL with SB_LINEDOWN, but how to set 100px? and how mush pixels scrolling down by SB_LINEDOWN?

UPD2:

I try

        SCROLLINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cbSize = sizeof(si);
    si.fMask = SIF_ALL;

    if (GetScrollInfo(h, SB_VERT, &si))
    {
        si.nPos += 123;

        SetScrollInfo(h, SB_VERT, &si, TRUE);
        SendMessage(h, WM_VSCROLL, MAKEWPARAM(SB_THUMBTRACK, si.nPos), 0);
    }
    else
    {
        printf("no GetScrollInfo! %d", ::GetLastError());
    }

and receive printf "no GetScrollInfo! 1447" (1447 is ERROR_NO_SCROLLBARS aka "The window does not have scroll bars"), but "Internet Explorer_Server" has scrollbars!

1

1 Answers

0
votes

WM_VSCROLL lacks the precision to do what you want. However you should be able to do what you want with SetScrollPos(). You'll need to use GetScrollInfo() and do some calculation of how far to move the thumb though.

I'd imagine it's still tricky to get it accurate with the above method. What is it you're trying to achieve ? Likely there is a better way to achieve it than emulating a scroll.