C ++: Scroll of the scroll bar
SCROLLINFO scrollinfo;GetScrollInfo(SB_HORZ, &scrollinfo, SIF_ALL);switch (nSBCode){case SB_LINERIGHT: if (scrollinfo.nPos < scrollinfo.nMax){ scrollinfo.nPos += 10; SetScrollInfo(SB_HORZ, &scrollinfo); ScrollWindow(-10, 0);} break;}
Use GetScrollInfo to obtain the rolling information and save the information to the SCROLLINFO data.
Then, the nSBCode is used to determine the action of the scroll bar and the adjustment is made.
The following lists the functions related to scrolling.
afx_msg void OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
Meanings of parameters:
NSBCode
Specifies the scroll bar code that indicates the user's rolling request. This parameter can be one of the following values:
SB_LEFT scroll to the left.
SB_ENDSCROLL ends the scroll.
SB_LINELEFT scroll.
SB_LINERIGHT: Scroll permission.
SB_PAGELEFT scroll one page.
SB_PAGERIGHT: Scroll one page.
SB_RIGHT: scroll to the rightmost.
SB_THUMBPOSITION is the absolute position of the scroll. The current location isNPosParameter.
Drag SB_THUMBTRACK to the scroll box at the specified position. The current location isNPosParameter.
NPos
If the code of the scroll bar is SB_THUMBPOSITION or SB_THUMBTRACK, specify the scroll box position. Otherwise, it is not used. Based on the initial scroll size, nPos can be negative. Therefore, if necessary, convert to int.
PScrollBar
If the rolling message comes fromScroll bar Control, Including pointing to the control. // If the scroll control is manually added
If you click the window scroll bar, this parameter is NULL.
Pointers may be transient and should not be stored for future use.