windows_programming_notes.nbk: Home | Index | Next Page: GetSubMenu | Previous Page: GetScrollInfo


 GetScrollPos

The GetScrollPos function retrieves the current position of the scroll box (thumb) in the specified scroll bar. The current position is a relative value that depends on the current scrolling range. For example, if the scrolling range is 0 through 100 and the scroll box is in the middle of the bar, the current position is 50.

Note The GetScrollPos function is provided for backward compatibility. New applications should use the GetScrollInfo function.

Syntax

    int GetScrollPos(  
        HWND hWnd,
        int nBar
    );

Parameters

Return Value

If the function succeeds, the return value is the current position of the scroll box.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetScrollPos function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are limited to 16 bits of position data, the functions SetScrollPos, SetScrollRange, GetScrollPos, and [GetScrollRange] support 32-bit scroll bar position data. Thus, an application can call GetScrollPos while processing either the WM_HSCROLL or WM_VSCROLL messages to obtain 32-bit scroll bar position data.

To get the 32-bit position of the scroll box (thumb) during a SB_THUMBTRACK request code in a WM_HSCROLL or WM_VSCROLL message, use the GetScrollInfo function.

If the nBar parameter is SB_CTL and the window specified by the hWnd parameter is not a system scroll bar control, the system sends the SBM_GETPOS message to the window to obtain scroll bar information. This allows GetScrollPos to operate on a custom control that mimics a scroll bar. If the window does not handle the SBM_GETPOS message, the GetScrollPos function fails.

Function Information


windows_programming_notes.nbk: Home | Index | Next Page: GetSubMenu | Previous Page: GetScrollInfo


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time