Though an ancient programmer, I'm still fairly inexperienced in MFC and Windows programming in general. I'm trying to add automatic scrolling during dragging. CScrollView windows have this feature, but I want to be able to add it to any old window with built-in scrollbars (using WS_VSCROLL style). The easy way appears to be to send a WM_VSCROLL message when the cursor is over an area near the top or bottom of the window. I naively assumed that something like
SendMessage(WM_VSCROLL, SB_LINEDOWN);
might work, but it does not seemed to be passed on to the right window, presumably a child window that is the scroll bar. Then I thought that I could find a handle for the child window, and send the message to that. Tried various approaches, like
GetDescendantWindow(SB_VERT)
GetWindow(GW_CHILD)
but nothing seems to give me access to the scroll bar. The only way I have found to make it work is to use
SendMessageToDescendants(WM_VSCROLL, SB_LINEUP);
which seems inelegant, in that all child windows will have to process the message that is only aimed at one of them.
So what I would love to know is: can you get a handle to the built-in scroll bars? If so how; if not, why not? And can anyone suggest any better ways to add automatic scrolling to an arbitrary window type?