Chapter 18: Progress-Based Controls Visual C++ and MFC Fundamentals
The nSBCode argument is the type of scrolling that is being performed. Its possible
values are:
Value Description Role
SB_THUMBTRACK The thumb is being dragged to a
specific position
SB_UP The thumb has been positioned to the
maximum value of the scroll bar, to
the extreme right
Used to position the thumb to the
highest value of the range, unless the
thumb is already positioned there
SB_LINEUP The thumb is scrolling up, one line at
a time
Used to increase the position of the
thumb, usually by adding 1, unless
the thumb is already positioned there
SB_PAGEUP The thumb is scrolling up, one page
at a time
Refers to the page size of the
SCROLLINFO value to increase the
current position by one page
SB_PAGEDOWN The thumb is scrolling to the bottom,
one page at a time
Refers to the page size of the
SCROLLINFO value to decrease the
current position by one page
SB_LINEDOWN The thumb is scrolling to the bottom,
one line at a time
Used to decrease the position of the
thumb, usually by subtracting 1 to the
current value, unless the thumb is
already positioned there
SB_BOTTOM The thumb has been positioned to the
minimum value of the scroll bar, to
the bottom side of the scroll bar
Used to position the thumb to the
lowest value of the range
SB_THUMBPOSITION Absolute postion
SB_ENDSCROLL End Scroll Used to determine the end of the
scrolling
The nPos argument is used in connection with the SB_THUMBTRACK and the
SB_THUMBPOSITION values of the nSBCode argument. The value of nPos specifies
how much scrolling should be done.
The pScrollBar argument can be used to identify the particular scroll bar control needs to
be dealt with on this OnHScroll() event.
Practical Learning: Using the Scroll Bar Events
- Generate the WM_VSCROLL message of the dialog box and implement it as
follows:
void CPreviewerDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int CurPos = pScrollBar->GetScrollPos();
switch (nSBCode)
{
case SB_TOP:
CurPos = 0;
break;
case SB_LINEUP:
if (CurPos > 0)