using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32
{
/// Flags used to enable or disable scroll bars.
[PInvokeData("winuser.h")]
public enum ESB_FLAGS : uint
{
/// Disables both direction buttons on the specified scroll bar.
ESB_DISABLE_BOTH = 0x0003,
/// Disables the down direction button on the vertical scroll bar.
ESB_DISABLE_DOWN = 0x0002,
/// Disables the left direction button on the horizontal scroll bar.
ESB_DISABLE_LEFT = 0x0001,
///
/// Disables the left direction button on the horizontal scroll bar or the up direction button on the vertical scroll bar.
///
ESB_DISABLE_LTUP = ESB_DISABLE_LEFT,
/// Disables the right direction button on the horizontal scroll bar.
ESB_DISABLE_RIGHT = 0x0002,
///
/// Disables the right direction button on the horizontal scroll bar or the down direction button on the vertical scroll bar.
///
ESB_DISABLE_RTDN = ESB_DISABLE_RIGHT,
/// Disables the up direction button on the vertical scroll bar.
ESB_DISABLE_UP = 0x0001,
/// Enables both direction buttons on the specified scroll bar.
ESB_ENABLE_BOTH = 0x0000,
}
/// Specifies the scroll bar type.
[PInvokeData("winuser.h")]
public enum SB
{
/// The horizontal and vertical scroll bars.
SB_BOTH = 3,
/// The horizontal scroll bar.
SB_HORZ = 0,
/// The vertical scroll bar.
SB_VERT = 1,
/// The scroll bar control.
SB_CTL = 2,
}
/// Specifies flags that control scrolling.
[PInvokeData("winuser.h", MSDNShortId = "")]
[Flags]
public enum ScrollWindowFlags
{
///
/// Scrolls all child windows that intersect the rectangle pointed to by the prcScroll parameter. The child windows are scrolled
/// by the number of pixels specified by the dx and dy parameters. The system sends a WM_MOVE message to all child windows that
/// intersect the prcScroll rectangle, even if they do not move.
///
SW_SCROLLCHILDREN = 0x0001,
/// Invalidates the region identified by the hrgnUpdate parameter after scrolling.
SW_INVALIDATE = 0x0002,
///
/// Erases the newly invalidated region by sending a WM_ERASEBKGND message to the window when specified with the SW_INVALIDATE flag.
///
SW_ERASE = 0x0004,
///
/// Scrolls using smooth scrolling. Use the HIWORD portion of the flags parameter to indicate how much time, in milliseconds, the
/// smooth-scrolling operation should take.
///
SW_SMOOTHSCROLL = 0x0010,
}
/// Specifies the scroll bar parameters to set or retrieve.
[PInvokeData("winuser.h", MSDNShortId = "")]
[Flags]
public enum SIF
{
/// The nMin and nMax members contain the minimum and maximum values for the scrolling range.
SIF_RANGE = 0x0001,
/// The nPage member contains the page size for a proportional scroll bar.
SIF_PAGE = 0x0002,
/// The nPos member contains the scroll box position, which is not updated while the user drags the scroll box.
SIF_POS = 0x0004,
///
/// This value is used only when setting a scroll bar's parameters. If the scroll bar's new parameters make the scroll bar
/// unnecessary, disable the scroll bar instead of removing it.
///
SIF_DISABLENOSCROLL = 0x0008,
/// The nTrackPos member contains the current position of the scroll box while the user is dragging it.
SIF_TRACKPOS = 0x0010,
/// Combination of SIF_PAGE, SIF_POS, SIF_RANGE, and SIF_TRACKPOS.
SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS,
}
/// The EnableScrollBar function enables or disables one or both scroll bar arrows.
///
/// Type: HWND
/// Handle to a window or a scroll bar control, depending on the value of the wSBflags parameter.
///
///
/// Type: UINT
/// Specifies the scroll bar type. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_BOTH
///
/// Enables or disables the arrows on the horizontal and vertical scroll bars associated with the specified window. The hWnd
/// parameter must be the handle to the window.
///
///
/// -
/// SB_CTL
/// Indicates that the scroll bar is a scroll bar control. The hWnd must be the handle to the scroll bar control.
///
/// -
/// SB_HORZ
///
/// Enables or disables the arrows on the horizontal scroll bar associated with the specified window. The hWnd parameter must be the
/// handle to the window.
///
///
/// -
/// SB_VERT
///
/// Enables or disables the arrows on the vertical scroll bar associated with the specified window. The hWnd parameter must be the
/// handle to the window.
///
///
///
///
///
/// Type: UINT
///
/// Specifies whether the scroll bar arrows are enabled or disabled and indicates which arrows are enabled or disabled. This
/// parameter can be one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// ESB_DISABLE_BOTH
/// Disables both arrows on a scroll bar.
///
/// -
/// ESB_DISABLE_DOWN
/// Disables the down arrow on a vertical scroll bar.
///
/// -
/// ESB_DISABLE_LEFT
/// Disables the left arrow on a horizontal scroll bar.
///
/// -
/// ESB_DISABLE_LTUP
/// Disables the left arrow on a horizontal scroll bar or the up arrow of a vertical scroll bar.
///
/// -
/// ESB_DISABLE_RIGHT
/// Disables the right arrow on a horizontal scroll bar.
///
/// -
/// ESB_DISABLE_RTDN
/// Disables the right arrow on a horizontal scroll bar or the down arrow of a vertical scroll bar.
///
/// -
/// ESB_DISABLE_UP
/// Disables the up arrow on a vertical scroll bar.
///
/// -
/// ESB_ENABLE_BOTH
/// Enables both arrows on a scroll bar.
///
///
///
///
/// Type: BOOL
/// If the arrows are enabled or disabled as specified, the return value is nonzero.
///
/// If the arrows are already in the requested state or an error occurs, the return value is zero. To get extended error information,
/// call GetLastError.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-enablescrollbar BOOL EnableScrollBar( HWND hWnd, UINT
// wSBflags, UINT wArrows );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnableScrollBar(HWND hWnd, uint wSBflags, uint wArrows);
/// The GetScrollBarInfo function retrieves information about the specified scroll bar.
///
/// Type: HWND
///
/// Handle to a window associated with the scroll bar whose information is to be retrieved. If the idObject parameter is
/// OBJID_CLIENT, hwnd is a handle to a scroll bar control. Otherwise, hwnd is a handle to a window created with WS_VSCROLL and/or
/// WS_HSCROLL style.
///
///
///
/// Type: LONG
/// Specifies the scroll bar object. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// OBJID_CLIENT
/// The hwnd parameter is a handle to a scroll bar control.
///
/// -
/// OBJID_HSCROLL
/// The horizontal scroll bar of the hwnd window.
///
/// -
/// OBJID_VSCROLL
/// The vertical scroll bar of the hwnd window.
///
///
///
///
/// Type: PSCROLLBARINFO
///
/// Pointer to a SCROLLBARINFO structure to receive the information. Before calling GetScrollBarInfo, set the cbSize
/// member to sizeof( SCROLLBARINFO).
///
///
///
/// Type: BOOL
/// 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.
///
///
/// If idObject is OBJID_CLIENT and the window specified by hwnd is not a system scroll bar control, the system sends the
/// SBM_GETSCROLLBARINFO message to the window to obtain scroll bar information. This allows GetScrollBarInfo to operate on a
/// custom control that mimics a scroll bar. If the window does not handle the SBM_GETSCROLLBARINFO message, the
/// GetScrollBarInfo function fails.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getscrollbarinfo BOOL GetScrollBarInfo( HWND hwnd, LONG
// idObject, PSCROLLBARINFO psbi );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetScrollBarInfo(HWND hwnd, int idObject, ref SCROLLBARINFO psbi);
///
/// The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling
/// positions, the page size, and the position of the scroll box (thumb).
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter.
///
///
/// Type: int
/// Specifies the type of scroll bar for which to retrieve parameters. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_CTL
/// Retrieves the parameters for a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
///
/// -
/// SB_HORZ
/// Retrieves the parameters for the window's standard horizontal scroll bar.
///
/// -
/// SB_VERT
/// Retrieves the parameters for the window's standard vertical scroll bar.
///
///
///
///
/// Type: LPSCROLLINFO
///
/// Pointer to a SCROLLINFO structure. Before calling GetScrollInfo, set the cbSize member to sizeof(
/// SCROLLINFO), and set the fMask member to specify the scroll bar parameters to retrieve. Before returning, the
/// function copies the specified parameters to the appropriate members of the structure.
///
/// The fMask member can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SIF_PAGE
/// Copies the scroll page to the nPage member of the SCROLLINFO structure pointed to by lpsi.
///
/// -
/// SIF_POS
/// Copies the scroll position to the nPos member of the SCROLLINFO structure pointed to by lpsi.
///
/// -
/// SIF_RANGE
/// Copies the scroll range to the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.
///
/// -
/// SIF_TRACKPOS
/// Copies the current scroll box tracking position to the nTrackPos member of the SCROLLINFO structure pointed to by lpsi.
///
///
///
///
/// Type: BOOL
/// If the function retrieved any values, the return value is nonzero.
/// If the function does not retrieve any values, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The GetScrollInfo function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll
/// bar position, WM_HSCROLL and WM_VSCROLL, provide only 16 bits of position data, the functions SetScrollInfo and
/// GetScrollInfo provide 32 bits of scroll bar position data. Thus, an application can call GetScrollInfo 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,
/// call GetScrollInfo with the SIF_TRACKPOS value in the fMask member of the SCROLLINFO structure. The function
/// returns the tracking position of the scroll box in the nTrackPos member of the SCROLLINFO structure. This allows
/// you to get the position of the scroll box as the user moves it. The following sample code illustrates the technique.
///
///
/// If the fnBar parameter is SB_CTL and the window specified by the hwnd parameter is not a system scroll bar control, the system
/// sends the SBM_GETSCROLLINFO message to the window to obtain scroll bar information. This allows GetScrollInfo to operate
/// on a custom control that mimics a scroll bar. If the window does not handle the SBM_GETSCROLLINFO message, the
/// GetScrollInfo function fails.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getscrollinfo BOOL GetScrollInfo( HWND hwnd, int nBar,
// LPSCROLLINFO lpsi );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetScrollInfo(HWND hwnd, int nBar, ref SCROLLINFO lpsi);
///
///
/// 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.
///
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
///
///
/// Type: int
/// Specifies the scroll bar to be examined. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_CTL
///
/// Retrieves 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
/// Retrieves the position of the scroll box in a window's standard horizontal scroll bar.
///
/// -
/// SB_VERT
/// Retrieves the position of the scroll box in a window's standard vertical scroll bar.
///
///
///
///
/// Type: int
/// 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.
///
///
///
/// 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.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getscrollpos int GetScrollPos( HWND hWnd, int nBar );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern int GetScrollPos(HWND hWnd, int nBar);
///
///
/// The GetScrollRange function retrieves the current minimum and maximum scroll box (thumb) positions for the specified
/// scroll bar.
///
///
/// Note The GetScrollRange function is provided for compatibility only. New applications should use the GetScrollInfo function.
///
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
///
///
/// Type: int
/// Specifies the scroll bar from which the positions are retrieved. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_CTL
/// Retrieves the positions of a scroll bar control. The hWnd parameter must be the handle to the scroll bar control.
///
/// -
/// SB_HORZ
/// Retrieves the positions of the window's standard horizontal scroll bar.
///
/// -
/// SB_VERT
/// Retrieves the positions of the window's standard vertical scroll bar.
///
///
///
///
/// Type: LPINT
/// Pointer to the integer variable that receives the minimum position.
///
///
/// Type: LPINT
/// Pointer to the integer variable that receives the maximum position.
///
///
/// Type: BOOL
/// 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.
///
///
///
/// If the specified window does not have standard scroll bars or is not a scroll bar control, the GetScrollRange function
/// copies zero to the lpMinPos and lpMaxPos parameters.
///
///
/// The default range for a standard scroll bar is 0 through 100. The default range for a scroll bar control is empty (both values
/// are zero).
///
///
/// The messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are limited to 16 bits of position data. However,
/// because SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange 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
/// the GetScrollInfo function for a description of the technique.
///
///
/// 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_GETRANGE message to the window to obtain scroll bar information. This allows GetScrollRange to operate on a
/// custom control that mimics a scroll bar. If the window does not handle the SBM_GETRANGE message, the GetScrollRange
/// function fails.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getscrollrange BOOL GetScrollRange( HWND hWnd, int nBar,
// LPINT lpMinPos, LPINT lpMaxPos );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetScrollRange(HWND hWnd, int nBar, out int lpMinPos, out int lpMaxPos);
/// The ScrollDC function scrolls a rectangle of bits horizontally and vertically.
///
/// Type: HDC
/// Handle to the device context that contains the bits to be scrolled.
///
///
/// Type: int
///
/// Specifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.
///
///
///
/// Type: int
/// Specifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.
///
///
/// Type: const RECT*
///
/// Pointer to a RECT structure containing the coordinates of the bits to be scrolled. The only bits affected by the scroll operation
/// are bits in the intersection of this rectangle and the rectangle specified by lprcClip. If lprcScroll is NULL, the entire
/// client area is used.
///
///
///
/// Type: const RECT*
///
/// Pointer to a RECT structure containing the coordinates of the clipping rectangle. The only bits that will be painted are the bits
/// that remain inside this rectangle after the scroll operation has been completed. If lprcClip is NULL, the entire client
/// area is used.
///
///
///
/// Type: HRGN
///
/// Handle to the region uncovered by the scrolling process. ScrollDC defines this region; it is not necessarily a rectangle.
///
///
///
/// Type: LPRECT
///
/// Pointer to a RECT structure that receives the coordinates of the rectangle bounding the scrolling update region. This is the
/// largest rectangular area that requires repainting. When the function returns, the values in the structure are in client
/// coordinates, regardless of the mapping mode for the specified device context. This allows applications to use the update region
/// in a call to the InvalidateRgn function, if required.
///
///
///
/// Type: BOOL
/// 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.
///
///
///
/// If the lprcUpdate parameter is NULL, the system does not compute the update rectangle. If both the hrgnUpdate and
/// lprcUpdate parameters are NULL, the system does not compute the update region. If hrgnUpdate is not NULL, the
/// system proceeds as though it contains a valid handle to the region uncovered by the scrolling process (defined by ScrollDC).
///
/// When you must scroll the entire client area of a window, use the ScrollWindowEx function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-scrolldc BOOL ScrollDC( HDC hDC, int dx, int dy, const
// RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ScrollDC(HDC hDC, int dx, int dy, PRECT lprcScroll, PRECT lprcClip, HRGN hrgnUpdate, out RECT lprcUpdate);
///
/// The ScrollWindow function scrolls the contents of the specified window's client area.
///
/// Note The ScrollWindow function is provided for backward compatibility. New applications should use the
/// ScrollWindowEx function.
///
///
///
/// Type: HWND
/// Handle to the window where the client area is to be scrolled.
///
///
/// Type: int
///
/// Specifies the amount, in device units, of horizontal scrolling. If the window being scrolled has the CS_OWNDC or CS_CLASSDC
/// style, then this parameter uses logical units rather than device units. This parameter must be a negative value to scroll the
/// content of the window to the left.
///
///
///
/// Type: int
///
/// Specifies the amount, in device units, of vertical scrolling. If the window being scrolled has the CS_OWNDC or CS_CLASSDC style,
/// then this parameter uses logical units rather than device units. This parameter must be a negative value to scroll the content of
/// the window up.
///
///
///
/// Type: const RECT*
///
/// Pointer to the RECT structure specifying the portion of the client area to be scrolled. If this parameter is NULL, the
/// entire client area is scrolled.
///
///
///
/// Type: const RECT*
///
/// Pointer to the RECT structure containing the coordinates of the clipping rectangle. Only device bits within the clipping
/// rectangle are affected. Bits scrolled from the outside of the rectangle to the inside are painted; bits scrolled from the inside
/// of the rectangle to the outside are not painted.
///
///
///
/// Type: BOOL
/// 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.
///
///
///
/// If the caret is in the window being scrolled, ScrollWindow automatically hides the caret to prevent it from being erased
/// and then restores the caret after the scrolling is finished. The caret position is adjusted accordingly.
///
///
/// The area uncovered by ScrollWindow is not repainted, but it is combined into the window's update region. The application
/// eventually receives a WM_PAINT message notifying it that the region must be repainted. To repaint the uncovered area at the same
/// time the scrolling is in action, call the UpdateWindow function immediately after calling ScrollWindow.
///
///
/// If the lpRect parameter is NULL, the positions of any child windows in the window are offset by the amount specified by
/// the XAmount and YAmount parameters; invalid (unpainted) areas in the window are also offset. ScrollWindow is faster when
/// lpRect is NULL.
///
///
/// If lpRect is not NULL, the positions of child windows are not changed and invalid areas in the window are not offset. To
/// prevent updating problems when lpRect is not NULL, call UpdateWindow to repaint the window before calling ScrollWindow.
///
/// Examples
/// For an example, see Scrolling Text with the WM_PAINT Message.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-scrollwindow BOOL ScrollWindow( HWND hWnd, int XAmount,
// int YAmount, const RECT *lpRect, const RECT *lpClipRect );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ScrollWindow(HWND hWnd, int XAmount, int YAmount, PRECT lpRect, in RECT lpClipRect);
/// The ScrollWindowEx function scrolls the contents of the specified window's client area.
///
/// Type: HWND
/// Handle to the window where the client area is to be scrolled.
///
///
/// Type: int
///
/// Specifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.
///
///
///
/// Type: int
/// Specifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.
///
///
/// Type: const RECT*
///
/// Pointer to a RECT structure that specifies the portion of the client area to be scrolled. If this parameter is NULL, the
/// entire client area is scrolled.
///
///
///
/// Type: const RECT*
///
/// Pointer to a RECT structure that contains the coordinates of the clipping rectangle. Only device bits within the clipping
/// rectangle are affected. Bits scrolled from the outside of the rectangle to the inside are painted; bits scrolled from the inside
/// of the rectangle to the outside are not painted. This parameter may be NULL.
///
///
///
/// Type: HRGN
/// Handle to the region that is modified to hold the region invalidated by scrolling. This parameter may be NULL.
///
///
/// Type: LPRECT
///
/// Pointer to a RECT structure that receives the boundaries of the rectangle invalidated by scrolling. This parameter may be NULL.
///
///
///
/// Type: UINT
/// Specifies flags that control scrolling. This parameter can be a combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SW_ERASE
///
/// Erases the newly invalidated region by sending a WM_ERASEBKGND message to the window when specified with the SW_INVALIDATE flag.
///
///
/// -
/// SW_INVALIDATE
/// Invalidates the region identified by the hrgnUpdate parameter after scrolling.
///
/// -
/// SW_SCROLLCHILDREN
///
/// Scrolls all child windows that intersect the rectangle pointed to by the prcScroll parameter. The child windows are scrolled by
/// the number of pixels specified by the dx and dy parameters. The system sends a WM_MOVE message to all child windows that
/// intersect the prcScroll rectangle, even if they do not move.
///
///
/// -
/// SW_SMOOTHSCROLL
///
/// Scrolls using smooth scrolling. Use the HIWORD portion of the flags parameter to indicate how much time, in milliseconds, the
/// smooth-scrolling operation should take.
///
///
///
///
///
/// Type: int
///
/// If the function succeeds, the return value is SIMPLEREGION (rectangular invalidated region), COMPLEXREGION (nonrectangular
/// invalidated region; overlapping rectangles), or NULLREGION (no invalidated region).
///
/// If the function fails, the return value is ERROR. To get extended error information, call GetLastError.
///
///
///
/// If the SW_INVALIDATE and SW_ERASE flags are not specified, ScrollWindowEx does not invalidate the area that is scrolled
/// from. If either of these flags is set, ScrollWindowEx invalidates this area. The area is not updated until the application
/// calls the UpdateWindow function, calls the RedrawWindow function (specifying the RDW_UPDATENOW or RDW_ERASENOW flag), or
/// retrieves the WM_PAINT message from the application queue.
///
///
/// If the window has the WS_CLIPCHILDREN style, the returned areas specified by hrgnUpdate and prcUpdate represent the total area of
/// the scrolled window that must be updated, including any areas in child windows that need updating.
///
///
/// If the SW_SCROLLCHILDREN flag is specified, the system does not properly update the screen if part of a child window is scrolled.
/// The part of the scrolled child window that lies outside the source rectangle is not erased and is not properly redrawn in its new
/// destination. To move child windows that do not lie completely within the rectangle specified by prcScroll, use the DeferWindowPos
/// function. The cursor is repositioned if the SW_SCROLLCHILDREN flag is set and the caret rectangle intersects the scroll rectangle.
///
///
/// All input and output coordinates (for prcScroll, prcClip, prcUpdate, and hrgnUpdate) are determined as client coordinates,
/// regardless of whether the window has the CS_OWNDC or CS_CLASSDC class style. Use the LPtoDP and DPtoLP functions to convert to
/// and from logical coordinates, if necessary.
///
/// Examples
/// For an example, see Scrolling Text with the WM_PAINT Message.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-scrollwindowex int ScrollWindowEx( HWND hWnd, int dx, int
// dy, const RECT *prcScroll, const RECT *prcClip, HRGN hrgnUpdate, LPRECT prcUpdate, UINT flags );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern int ScrollWindowEx(HWND hWnd, int dx, int dy, PRECT prcScroll, PRECT prcClip, HRGN hrgnUpdate, out RECT prcUpdate, ScrollWindowFlags flags);
///
/// The SetScrollInfo function sets the parameters of a scroll bar, including the minimum and maximum scrolling positions, the
/// page size, and the position of the scroll box (thumb). The function also redraws the scroll bar, if requested.
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter.
///
///
/// Type: int
/// Specifies the type of scroll bar for which to set parameters. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_CTL
/// Sets the parameters of a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
///
/// -
/// SB_HORZ
/// Sets the parameters of the window's standard horizontal scroll bar.
///
/// -
/// SB_VERT
/// Sets the parameters of the window's standard vertical scroll bar.
///
///
///
///
/// Type: LPCSCROLLINFO
///
/// Pointer to a SCROLLINFO structure. Before calling SetScrollInfo, set the cbSize member of the structure to
/// sizeof( SCROLLINFO), set the fMask member to indicate the parameters to set, and specify the new parameter
/// values in the appropriate members.
///
/// The fMask member can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SIF_DISABLENOSCROLL
/// Disables the scroll bar instead of removing it, if the scroll bar's new parameters make the scroll bar unnecessary.
///
/// -
/// SIF_PAGE
/// Sets the scroll page to the value specified in the nPage member of the SCROLLINFO structure pointed to by lpsi.
///
/// -
/// SIF_POS
/// Sets the scroll position to the value specified in the nPos member of the SCROLLINFO structure pointed to by lpsi.
///
/// -
/// SIF_RANGE
/// Sets the scroll range to the value specified in the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.
///
///
///
///
/// Type: BOOL
///
/// Specifies whether the scroll bar is redrawn to reflect the changes to the scroll bar. If this parameter is TRUE, the
/// scroll bar is redrawn, otherwise, it is not redrawn.
///
///
///
/// Type: int
/// The return value is the current position of the scroll box.
///
///
///
/// The SetScrollInfo function performs range checking on the values specified by the nPage and nPos members of
/// the SCROLLINFO structure. The nPage member must specify a value from 0 to nMax - nMin +1. The nPos
/// member must specify a value between nMin and nMax - max( nPage– 1, 0). If either value is beyond its
/// range, the function sets it to a value that is just within the range.
///
///
/// If the fnBar parameter is SB_CTL and the window specified by the hwnd parameter is not a system scroll bar control, the system
/// sends the SBM_SETSCROLLINFO message to the window to set scroll bar information (The system can optimize the message to
/// SBM_SETPOS or SBM_SETRANGE if the request is solely for the position or range). This allows SetScrollInfo to operate on a
/// custom control that mimics a scroll bar. If the window does not handle SBM_SETSCROLLINFO (or the optimized
/// SBM_SETPOS message or SBM_SETRANGE message), then the SetScrollInfo function fails.
///
/// For an example, see Scrolling Text with the WM_PAINT Message.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setscrollinfo int SetScrollInfo( HWND hwnd, int nBar,
// LPCSCROLLINFO lpsi, BOOL redraw );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern int SetScrollInfo(HWND hwnd, int nBar, in SCROLLINFO lpsi, [MarshalAs(UnmanagedType.Bool)] bool redraw);
///
///
/// 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 should use the
/// SetScrollInfo function.
///
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
///
///
/// Type: int
/// 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.
///
///
///
///
/// Type: int
///
/// 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.
///
///
///
/// Type: BOOL
///
/// 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.
///
///
///
/// Type: int
/// If the function succeeds, the return value is the previous position of the scroll box.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// 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.
///
///
/// 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_SETPOS message to the window to set scroll bar information. This allows SetScrollPos to operate on a custom
/// control that mimics a scroll bar. If the window does not handle the SBM_SETPOS message, the SetScrollPos function fails.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setscrollpos int SetScrollPos( HWND hWnd, int nBar, int
// nPos, BOOL bRedraw );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern int SetScrollPos(HWND hWnd, int nBar, int nPos, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
///
/// 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 should use the
/// SetScrollInfo function.
///
///
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
///
///
/// Type: int
/// 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.
///
///
///
///
/// Type: int
/// Specifies the minimum scrolling position.
///
///
/// Type: int
/// Specifies the maximum scrolling position.
///
///
/// Type: BOOL
///
/// Specifies whether the scroll bar should 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.
///
///
///
/// Type: BOOL
/// 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.
///
///
///
/// You can use SetScrollRange to hide the scroll bar by setting nMinPos and nMaxPos to the same value. An application should
/// not call the SetScrollRange function to hide a scroll bar while processing a scroll bar message. New applications should
/// 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.
///
///
/// 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_SETRANGE message to the window to set scroll bar information. This allows SetScrollRange to operate on a
/// custom control that mimics a scroll bar. If the window does not handle the SBM_SETRANGE message, the SetScrollRange
/// function fails.
///
/// Examples
/// For an example, see Using the Owner-Display Clipboard Format.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setscrollrange BOOL SetScrollRange( HWND hWnd, int nBar,
// int nMinPos, int nMaxPos, BOOL bRedraw );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetScrollRange(HWND hWnd, int nBar, int nMinPos, int nMaxPos, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
/// The ShowScrollBar function shows or hides the specified scroll bar.
///
/// Type: HWND
/// Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the wBar parameter.
///
///
/// Type: int
/// Specifies the scroll bar(s) to be shown or hidden. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SB_BOTH
/// Shows or hides a window's standard horizontal and vertical scroll bars.
///
/// -
/// SB_CTL
/// Shows or hides a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
///
/// -
/// SB_HORZ
/// Shows or hides a window's standard horizontal scroll bars.
///
/// -
/// SB_VERT
/// Shows or hides a window's standard vertical scroll bar.
///
///
///
///
/// Type: BOOL
///
/// Specifies whether the scroll bar is shown or hidden. If this parameter is TRUE, the scroll bar is shown; otherwise, it is hidden.
///
///
///
/// Type: BOOL
/// 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.
///
/// You should not call this function to hide a scroll bar while processing a scroll bar message.
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-showscrollbar BOOL ShowScrollBar( HWND hWnd, int wBar,
// BOOL bShow );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowScrollBar(HWND hWnd, int wBar, [MarshalAs(UnmanagedType.Bool)] bool bShow);
/// The SCROLLBARINFO structure contains scroll bar information.
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagscrollbarinfo typedef struct tagSCROLLBARINFO { DWORD
// cbSize; RECT rcScrollBar; int dxyLineButton; int xyThumbTop; int xyThumbBottom; int reserved; DWORD rgstate[CCHILDREN_SCROLLBAR +
// 1]; } SCROLLBARINFO, *PSCROLLBARINFO, *LPSCROLLBARINFO;
[PInvokeData("winuser.h", MSDNShortId = "")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SCROLLBARINFO
{
///
/// Type: DWORD
///
/// Specifies the size, in bytes, of the structure. Before calling the GetScrollBarInfo function, set cbSize to
/// sizeof( SCROLLBARINFO).
///
///
public uint cbSize;
///
/// Type: RECT
/// Coordinates of the scroll bar as specified in a RECT structure.
///
public RECT rcScrollBar;
///
/// Type: int
/// Height or width of the thumb.
///
public int dxyLineButton;
///
/// Type: int
/// Position of the top or left of the thumb.
///
public int xyThumbTop;
///
/// Type: int
/// Position of the bottom or right of the thumb.
///
public int xyThumbBottom;
///
/// Type: int
/// Reserved.
///
public int reserved;
///
/// Type: DWORD[CCHILDREN_SCROLLBAR+1]
///
/// An array of DWORD elements. Each element indicates the state of a scroll bar component. The following values show the
/// scroll bar component that corresponds to each array index.
///
///
///
/// Index
/// Scroll bar component
///
/// -
/// 0
/// The scroll bar itself.
///
/// -
/// 1
/// The top or right arrow button.
///
/// -
/// 2
/// The page up or page right region.
///
/// -
/// 3
/// The scroll box (thumb).
///
/// -
/// 4
/// The page down or page left region.
///
/// -
/// 5
/// The bottom or left arrow button.
///
///
/// The DWORD element for each scroll bar component can include a combination of the following bit flags.
///
///
/// Value
/// Meaning
///
/// -
/// STATE_SYSTEM_INVISIBLE
///
/// For the scroll bar itself, indicates the specified vertical or horizontal scroll bar does not exist. For the page up or page
/// down regions, indicates the thumb is positioned such that the region does not exist.
///
///
/// -
/// STATE_SYSTEM_OFFSCREEN
///
/// For the scroll bar itself, indicates the window is sized such that the specified vertical or horizontal scroll bar is not
/// currently displayed.
///
///
/// -
/// STATE_SYSTEM_PRESSED
/// The arrow button or page region is pressed.
///
/// -
/// STATE_SYSTEM_UNAVAILABLE
/// The component is disabled.
///
///
///
/// The .
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public uint[] rgstate;
}
///
/// The SCROLLINFO structure contains scroll bar parameters to be set by the SetScrollInfo function (or SBM_SETSCROLLINFO
/// message), or retrieved by the GetScrollInfo function (or SBM_GETSCROLLINFO message).
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagscrollinfo typedef struct tagSCROLLINFO { UINT cbSize;
// UINT fMask; int nMin; int nMax; UINT nPage; int nPos; int nTrackPos; } SCROLLINFO, *LPSCROLLINFO;
[PInvokeData("winuser.h", MSDNShortId = "")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SCROLLINFO
{
///
/// Type: UINT
/// Specifies the size, in bytes, of this structure. The caller must set this to sizeof( SCROLLINFO).
///
public uint cbSize;
///
/// Type: UINT
/// Specifies the scroll bar parameters to set or retrieve. This member can be a combination of the following values:
///
///
/// Value
/// Meaning
///
/// -
/// SIF_ALL
/// Combination of SIF_PAGE, SIF_POS, SIF_RANGE, and SIF_TRACKPOS.
///
/// -
/// SIF_DISABLENOSCROLL
///
/// This value is used only when setting a scroll bar's parameters. If the scroll bar's new parameters make the scroll bar
/// unnecessary, disable the scroll bar instead of removing it.
///
///
/// -
/// SIF_PAGE
/// The nPage member contains the page size for a proportional scroll bar.
///
/// -
/// SIF_POS
/// The nPos member contains the scroll box position, which is not updated while the user drags the scroll box.
///
/// -
/// SIF_RANGE
/// The nMin and nMax members contain the minimum and maximum values for the scrolling range.
///
/// -
/// SIF_TRACKPOS
/// The nTrackPos member contains the current position of the scroll box while the user is dragging it.
///
///
///
public SIF fMask;
///
/// Type: int
/// Specifies the minimum scrolling position.
///
public int nMin;
///
/// Type: int
/// Specifies the maximum scrolling position.
///
public int nMax;
///
/// Type: UINT
///
/// Specifies the page size, in device units. A scroll bar uses this value to determine the appropriate size of the proportional
/// scroll box.
///
///
public uint nPage;
///
/// Type: int
/// Specifies the position of the scroll box.
///
public int nPos;
///
/// Type: int
///
/// Specifies the immediate position of a scroll box that the user is dragging. An application can retrieve this value while
/// processing the SB_THUMBTRACK request code. An application cannot set the immediate scroll position; the SetScrollInfo
/// function ignores this member.
///
///
public int nTrackPos;
}
}
}