Text02: function set of the primary scroll bar (msdn)

Source: Internet
Author: User

Setscrollrange
The setscrollrange function sets the minimum and maximum scroll Box positions for the specified scroll bar.

Note the setscrollrange function is provided for backward compatibility. New Applications shocould use the setscrollinfo function.

Bool setscrollrange (
Hwnd, // handle to window
Int nbar, // scroll bar
Int nminpos, // minimum scrolling position
Int nmaxpos, // maximum scrolling position
Bool bredraw // redraw flag
);
Parameters
Hwnd
[In] handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nbar parameter.
Nbar
[In] specifies the scroll bar to be set. This parameter can be one of the following values. Value Meaning
Sb_ctl sets the range of a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
Sb_horz sets the range of a window's standard horizontal scroll bar.
Sb_vert sets the range of a window's standard vertical scroll bar.

Nminpos
[In] specifies the minimum scrolling position.
Nmaxpos
[In] specifies the maximum scrolling position.
Bredraw
[In] specifies whether the scroll bar shocould be redrawn to reflect the change. If this parameter is true, the scroll bar is redrawn. If it is false, the scroll bar is not redrawn.
Return values
If the function succeeds, the return value is nonzero.

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

Remarks
You can use setscrollrange to hide the scroll bar by setting nminpos and nmaxpos to the same value. an application shoshould not call the setscrollrange function to hide a scroll bar while processing a scroll bar message. new applications shocould use the showscrollbar function to hide the scroll bar.

If the call to setscrollrange immediately follows a call to the setscrollpos function, the bredraw parameter in setscrollpos must be zero to prevent the scroll bar from being drawn twice.

The default range for a standard scroll bar is 0 through 100. the default range for a scroll bar control is empty (both the nminpos and nmaxpos parameter values are zero ). the difference between the values specified by the nminpos and nmaxpos parameters must not be greater than the value of maxlong.

Because the messages that indicate scroll bar position, wm_hscroll and wm_vscroll, are limited to 16 bits of position data, applications that rely solely on those messages for position data have a practical maximum value of 65,535 for the setscrollrange function's nmaxpos parameter.

However, because the setscrollinfo, setscrollpos, setscrollrange, getscrollinfo, getscrollpos, and getscrollrange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the wm_hscroll and wm_vscroll messages. see getscrollinfo for a description of the technique.

Example code
For an example, see using the owner-display clipboard format.

Requirements
Windows NT/2000/XP: supported ded in Windows NT 3.1 and later.
Windows 95/98/me: supported ded in Windows 95 and later.
Header: declared in winuser. h; Include windows. h.
Library: Use user32.lib.

See also
Scroll bars overview, scroll bar functions, getscrollinfo, getscrollpos, getscrollrange, setscrollinfo, setscrollpos, showscrollbar

Setscrollpos
The setscrollpos function sets the position of the scroll box (Thumb) in the specified scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box.

Note the setscrollpos function is provided for backward compatibility. New Applications shocould use the setscrollinfo function.

Int setscrollpos (
Hwnd, // handle to window
Int nbar, // scroll bar
Int NPOs, // new position of scroll box
Bool bredraw // redraw flag
);
Parameters
Hwnd
[In] handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nbar parameter.
Nbar
[In] specifies the scroll bar to be set. This parameter can be one of the following values. Value Meaning
Sb_ctl sets the position of the scroll box in a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
Sb_horz sets the position of the scroll box in a window's standard horizontal scroll bar.
Sb_vert sets the position of the scroll box in a window's standard vertical scroll bar.

NPOs
[In] specifies the new position of the scroll box. The position must be within the scrolling range. For more information about the scrolling range, see the setscrollrange function.
Bredraw
[In] specifies whether the scroll bar is redrawn to reflect the new scroll box position. if this parameter is true, the scroll bar is redrawn. if it is false, the scroll bar is not redrawn.
Return values
If the function succeeds, the return value is the previous position of the scroll box.

Windows XP: If the desktop is themed and the parent window is a message-only window, the function returns an incorrect value.

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

Remarks
If the scroll bar is redrawn by a subsequent call to another function, setting the bredraw parameter to false is useful.

Because the messages that indicate scroll bar position, wm_hscroll and wm_vscroll, are limited to 16 bits of position data, applications that rely solely on those messages for position data have a practical maximum value of 65,535 for the setscrollpos function's NPOs parameter.

However, because the setscrollinfo, setscrollpos, setscrollrange, getscrollinfo, getscrollpos, and getscrollrange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the wm_hscroll and wm_vscroll messages. see getscrollinfo for a description of the technique.

Requirements
Windows NT/2000/XP: supported ded in Windows NT 3.1 and later.
Windows 95/98/me: supported ded in Windows 95 and later.
Header: declared in winuser. h; Include windows. h.
Library: Use user32.lib.

See also
Scroll bars overview, scroll bar functions, getscrollinfo, getscrollpos, getscrollrange, setscrollinfo, setscrollrange

Invalidaterect
The invalidaterect function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.

Bool invalidaterect (
Hwnd, // handle to window
Const rect * lprect, // rectangle coordinates
Bool berase // erase state
);
Parameters
Hwnd
[In] handle to the window whose update region has changed. if this parameter is null, the system invalidates and redraws all windows, and sends the wm_erasebkgnd and wm_ncpaint messages to the window procedure before the function returns.
Lprect
[In] pointer to a rect structure that contains the client coordinates of the rectangle to be added to the update region. if this parameter is null, the entire client area is added to the update region.
Berase
[In] specifies whether the background within the update region is to be erased when the update region is processed. if this parameter is true, the background is erased when the beginpaint function is called. if this parameter is false, the background remains unchanged.
Return values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call getlasterror.

Remarks
The invalidated areas accumulate in the update region until the region is processed when the next wm_paint message occurs or until the region is validated by using the validaterect or validatergn function.

The system sends a wm_paint message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.

If the berase parameter is true for any part of the update region, the background is erased in the entire region, not just in the specified part.

Example code
For an example, see invalidating the client area.

Requirements
Windows NT/2000/XP: supported ded in Windows NT 3.1 and later.
Windows 95/98/me: supported ded in Windows 95 and later.
Header: declared in winuser. h; Include windows. h.
Library: Use user32.lib.

See also
Painting and drawing overview, painting and drawing functions, beginpaint, invalidatergn, rect, validaterect, validatergn, wm_erasebkgnd, wm_ncpaint, wm_paint

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.