OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Responding To Scroll-bar Messages

When the user moves a scroll bar's thumb or clicks the scroll arrows, Windows sends a scroll bar notification message to the parent window.

If 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, as shown in the following example:

class TTestWindow : public TFrameWindow {
public:
TTestWindow(TWindow* parent, const char* title);
virtual void SetupWindow();
void EvHScroll(UINT code, UINT pos, HWND wnd);
};
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define END_RESPONSE_TABLE
Definition eventhan.h:466
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
#define EV_WM_HSCROLL
Definition windowev.h:303

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, as shown in the following example:

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
}

See Also