
When the user moves a scroll bar’ thumb or clicks the scroll arrows,s
Responding to
Windows sends a scroll bar notification message to the parent window. If
scroll-bar messages
you want your window to respond to scrolling events, respond to the
notification messages.
Scroll bar notification messages are slightly different from other control
notification messages. They’re based on the WM_HSCROLL and
WM_VSCROLL messages, rather than WM_COMMAND command
messages. Therefore, to respond to scroll bar notification messages, you
need to define EvHScroll or EvVScroll event response functions, depending
on whether the scroll bar is horizontal or vertical:
class TTestWindow : public TFrameWindow {
public:
TTestWindow(TWindow* parent, const char* title);
virtual void SetupWindow();
void EvHScroll(UINT code, UINT pos, HWND wnd);
DECLARE_RESPONSE_TABLE(TTestWindow);
};
DEFINE_RESPONSE_TABLE1(TTestWindow, TFrameWindow)
EV_WM_HSCROLL,
END_RESPONSE_TABLE;
Usually you respond to all the scroll bar notification messages by,
retrieving the current thumb position and taking appropriate action. In that
case, you can ignore the notification code:
void TTestWindow::EvHScroll(UINT code, UINT pos, HWND wnd)
{
TFrameWindow::EvHScroll(); // perform default WM_HSCROLL processing
int newPos = ScrollBar->GetPosition();
// do some processing with newPos
}
A oiding thumb tracking messagesv
Y u might not want to respond to the scroll bar notification messages whileo
the user is dragging the scroll bar’ thumb, because the user is usuallys
dragging the thumb quickly generating many notification messages. It’, s
more efficient to wait until the user has stopped moving the thumb, and
then respond. T do this, screen out the notification messages that have theo
SB_THUMBTRA K code.C
Chapter 10, Control objects
239