Trapping WM_VSCROLL & Multiple Listboxes

I have a main window with three listboxes. All are controlled by one INT_PTR CALLBACK proc. How do I get a handle to the scrollbar in one of these listboxes so that the WM_VSCROLL message is handled.

I've tried stuff like --

1
2
case WM_VSCROLL:
if(LOWORD(wParam)==IDL_LISTBOX1)


and so forth, but I cannot get it to work. What I would like is some simple code to show me how to, say, make a simple MessageBox pop up when I do a page down on one of the listbox scrollbars.
Have you subclassed the listboxes Lamblion? I would sure think that somewhere in the listbox code is a window receiving WM_VSCROLL messages. Can't say I've ever tried to do that though with listboxes & WM_VSCROLL messages.
I don't know exactly what subclass means, or how to do it. I've been told that by two other people, and given a link on subclassing, but I haven't gotten into it yet. I'm sure it's probably something simple, but I just haven't gotten into it.
Stated as simply as possible, the Window Procedure is one of the absolute fundamental concepts of low level Windows Api programming. A listbox is one of the basic pre-defined window classes. Others are of course buttons, edit boxes, labels (static window class), combo boxes, and so forth. When you create a program and decorate your windows/dialogs/forms with any of these controls, your window procedure in your program will only receive a small subset of the actual messages generated through the user's interaction with these controls. This is because the window procedure for these controls is within windows code - not your code. In cases where you need to interact with these controls in some non-standard custom way, it is possible to 'hook' the internal window procedures and receive all the messages you otherwise wouldn't get within a special window procedure you have to define in your app. After you receive these messages you need to route them through the original window procedure or you'll break the control entirely. Its not really that hard to do. A classic and fairly simple example of this sort of thing would be subclassing an edit box to intercept when the user hits the [ENTER] key to move the focus to another control. Check out the SetWindowLong() Api function.
Thank you for that explanation. I sort of had an idea, but your explanation makes it much more clear to me. I have not had time to fool with it yet, but at least I've got a foundation to build on.
Topic archived. No new replies allowed.