using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32
{
///
/// The DrawStateProc function is an application-defined callback function that renders a complex image for the DrawState
/// function. The DRAWSTATEPROC type defines a pointer to this callback function. DrawStateProc is a placeholder for
/// the application-defined function name.
///
///
/// A handle to the device context to draw in. The device context is a memory device context with a bitmap selected, the dimensions
/// of which are at least as great as those specified by the cx and cy parameters.
///
/// Specifies information about the image, which the application passed to DrawState.
/// Specifies information about the image, which the application passed to DrawState.
/// The image width, in device units, as specified by the call to DrawState.
/// The image height, in device units, as specified by the call to DrawState.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nc-winuser-drawstateproc DRAWSTATEPROC Drawstateproc; BOOL
// Drawstateproc( HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy ) {...}
[PInvokeData("winuser.h", MSDNShortId = "a95a4020-e433-4b2c-96e7-f272e28e5a43")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool DrawStateProc(HDC hdc, IntPtr lData, IntPtr wData, int cx, int cy);
///
/// The OutputProc function is an application-defined callback function used with the GrayString function. It is used to draw
/// a string. The GRAYSTRINGPROC type defines a pointer to this callback function. OutputProc is a placeholder for the
/// application-defined or library-defined function name.
///
///
/// A handle to a device context with a bitmap of at least the width and height specified by the nWidth and nHeight parameters passed
/// to GrayString.
///
/// A pointer to the string to be drawn.
/// The length, in characters, of the string.
///
/// If it succeeds, the callback function should return TRUE.
/// If the function fails, the return value is FALSE.
///
/// The callback function must draw an image relative to the coordinates (0,0).
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nc-winuser-graystringproc GRAYSTRINGPROC Graystringproc; BOOL
// Graystringproc( HDC Arg1, LPARAM Arg2, int Arg3 ) {...}
[PInvokeData("winuser.h", MSDNShortId = "4d9145d2-5be4-4da3-9d03-01ebd74e0d06")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool OutputProc(HDC hdc, string lpData, int cchData);
/// Flags used by the method.
[PInvokeData("WinUser.h")]
[Flags]
public enum BorderFlags : uint
{
/// Left side of border rectangle.
BF_LEFT = 0x0001,
/// Top of border rectangle.
BF_TOP = 0x0002,
/// Right side of border rectangle.
BF_RIGHT = 0x0004,
/// Bottom of border rectangle.
BF_BOTTOM = 0x0008,
/// Top and left side of border rectangle.
BF_TOPLEFT = BF_TOP | BF_LEFT,
/// Top and right side of border rectangle.
BF_TOPRIGHT = BF_TOP | BF_RIGHT,
/// Bottom and left side of border rectangle.
BF_BOTTOMLEFT = BF_BOTTOM | BF_LEFT,
/// Bottom and right side of border rectangle.
BF_BOTTOMRIGHT = BF_BOTTOM | BF_RIGHT,
/// Entire border rectangle.
BF_RECT = BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM,
/// Diagonal border.
BF_DIAGONAL = 0x0010,
/// Diagonal border. The end point is the top-right corner of the rectangle; the origin is lower-left corner.
BF_DIAGONAL_ENDTOPRIGHT = BF_DIAGONAL | BF_TOP | BF_RIGHT,
/// Diagonal border. The end point is the top-left corner of the rectangle; the origin is lower-right corner.
BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL | BF_TOP | BF_LEFT,
/// Diagonal border. The end point is the lower-left corner of the rectangle; the origin is top-right corner.
BF_DIAGONAL_ENDBOTTOMLEFT = BF_DIAGONAL | BF_BOTTOM | BF_LEFT,
/// Diagonal border. The end point is the lower-right corner of the rectangle; the origin is top-left corner.
BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL | BF_BOTTOM | BF_RIGHT,
/// Interior of rectangle to be filled.
BF_MIDDLE = 0x0800,
/// Soft buttons instead of tiles.
BF_SOFT = 0x1000,
///
/// The rectangle pointed to by the pDestRect parameter is shrunk to exclude the edges that were drawn; otherwise the rectangle
/// does not change.
///
BF_ADJUST = 0x2000,
/// Flat border.
BF_FLAT = 0x4000,
/// One-dimensional border.
BF_MONO = 0x8000,
}
/// Styles used by the method.
[PInvokeData("WinUser.h")]
[Flags]
public enum BorderStyles3D : uint
{
/// Raised outer edge
BDR_RAISEDOUTER = 0x0001,
/// Sunken outer edge
BDR_SUNKENOUTER = 0x0002,
/// Raised inner edge
BDR_RAISEDINNER = 0x0004,
/// Sunken inner edge
BDR_SUNKENINNER = 0x0008,
/// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER
BDR_OUTER = BDR_RAISEDOUTER | BDR_SUNKENOUTER,
/// Combination of BDR_RAISEDINNER and BDR_SUNKENINNER
BDR_INNER = BDR_RAISEDINNER | BDR_SUNKENINNER,
/// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER
BDR_RAISED = BDR_RAISEDOUTER | BDR_RAISEDINNER,
/// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER
BDR_SUNKEN = BDR_SUNKENOUTER | BDR_SUNKENINNER,
/// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER
EDGE_RAISED = BDR_RAISEDOUTER | BDR_RAISEDINNER,
/// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER
EDGE_SUNKEN = BDR_SUNKENOUTER | BDR_SUNKENINNER,
/// Combination of BDR_SUNKENOUTER and BDR_RAISEDINNER
EDGE_ETCHED = BDR_SUNKENOUTER | BDR_RAISEDINNER,
/// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER
EDGE_BUMP = BDR_RAISEDOUTER | BDR_SUNKENINNER,
}
/// Flags used by .
[PInvokeData("winuser.h", MSDNShortId = "9348e29f-ce56-4664-8862-f5810c797622")]
[Flags]
public enum DrawCaptionFlags
{
/// The function uses the colors that denote an active caption.
DC_ACTIVE = 0x0001,
/// The function draws a small caption, using the current small caption font.
DC_SMALLCAP = 0x0002,
/// The function draws the icon when drawing the caption text.
DC_ICON = 0x0004,
/// The function draws the caption text when drawing the caption.
DC_TEXT = 0x0008,
/// The function draws the caption as a button.
DC_INBUTTON = 0x0010,
///
/// When this flag is set, the function uses COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or
/// COLOR_GRADIENTINACTIVECAPTION for the title-bar color.
/// If this flag is not set, the function uses COLOR_ACTIVECAPTION or COLOR_INACTIVECAPTION for both colors.
///
DC_GRADIENT = 0x0020,
/// If set, the function draws the buttons in the caption bar (to minimize, restore, or close an application).
DC_BUTTONS = 0x1000,
}
/// Flags used by .
[PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")]
[Flags]
public enum DrawStateFlags
{
///
/// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter.
///
DST_COMPLEX = 0x0000,
///
/// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is
/// zero, the string must be null-terminated.
///
DST_TEXT = 0x0001,
/// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character
/// as a directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData
/// parameter specifies the length. If wData is zero, the string must be null-terminated.
DST_PREFIXTEXT = 0x0002,
/// The image is an icon. The lData parameter is the icon handle.
DST_ICON = 0x0003,
///
/// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an
/// existing device context.
///
DST_BITMAP = 0x0004,
/// Draws the image without any modification.
DSS_NORMAL = 0x0000,
/// Dithers the image.
DSS_UNION = 0x0010,
/// Embosses the image.
DSS_DISABLED = 0x0020,
/// Draws the image using the brush specified by the hbr parameter.
DSS_MONO = 0x0080,
/// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This
/// must be used with DST_PREFIXTEXT.
DSS_HIDEPREFIX = 0x0200,
/// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the
/// string is drawn. This must be used with DST_PREFIXTEXT.
DSS_PREFIXONLY = 0x0400,
/// Aligns the text to the right.
DSS_RIGHT = 0x8000,
}
/// State of the control to draw with .
[PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")]
[Flags]
public enum FrameControlState
{
/// Close button
DFCS_CAPTIONCLOSE = 0x0000,
/// Minimize button
DFCS_CAPTIONMIN = 0x0001,
/// Maximize button
DFCS_CAPTIONMAX = 0x0002,
/// Restore button
DFCS_CAPTIONRESTORE = 0x0003,
/// Help button
DFCS_CAPTIONHELP = 0x0004,
/// Submenu arrow
DFCS_MENUARROW = 0x0000,
/// Check mark
DFCS_MENUCHECK = 0x0001,
/// Bullet
DFCS_MENUBULLET = 0x0002,
///
/// Submenu arrow pointing left. This is used for the right-to-left cascading menus used with right-to-left languages such as
/// Arabic or Hebrew.
///
DFCS_MENUARROWRIGHT = 0x0004,
/// Up arrow of scroll bar
DFCS_SCROLLUP = 0x0000,
/// Down arrow of scroll bar
DFCS_SCROLLDOWN = 0x0001,
/// Left arrow of scroll bar
DFCS_SCROLLLEFT = 0x0002,
/// Right arrow of scroll bar
DFCS_SCROLLRIGHT = 0x0003,
/// Combo box scroll bar
DFCS_SCROLLCOMBOBOX = 0x0005,
/// Size grip in lower-right corner of window
DFCS_SCROLLSIZEGRIP = 0x0008,
/// Size grip in lower-left corner of window. This is used with right-to-left languages such as Arabic or Hebrew.
DFCS_SCROLLSIZEGRIPRIGHT = 0x0010,
/// Check box
DFCS_BUTTONCHECK = 0x0000,
/// Image for radio button (nonsquare needs image)
DFCS_BUTTONRADIOIMAGE = 0x0001,
/// Mask for radio button (nonsquare needs mask)
DFCS_BUTTONRADIOMASK = 0x0002,
/// Radio button
DFCS_BUTTONRADIO = 0x0004,
/// Three-state button
DFCS_BUTTON3STATE = 0x0008,
/// Push button
DFCS_BUTTONPUSH = 0x0010,
/// Button is inactive (grayed).
DFCS_INACTIVE = 0x0100,
/// Button is pushed.
DFCS_PUSHED = 0x0200,
/// Button is checked.
DFCS_CHECKED = 0x0400,
/// The background remains untouched. This flag can only be combined with DFCS_MENUARROWUP or DFCS_MENUARROWDOWN.
DFCS_TRANSPARENT = 0x0800,
/// Button is hot-tracked.
DFCS_HOT = 0x1000,
/// Bounding rectangle is adjusted to exclude the surrounding edge of the push button.
DFCS_ADJUSTRECT = 0x2000,
/// Button has a flat border.
DFCS_FLAT = 0x4000,
/// Button has a monochrome border.
DFCS_MONO = 0x8000,
}
/// Type of control to draw with .
[PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")]
public enum FrameControlType
{
/// Title bar.
DFC_CAPTION = 1,
/// Menu bar.
DFC_MENU = 2,
/// Scroll bar.
DFC_SCROLL = 3,
/// Standard button.
DFC_BUTTON = 4,
/// Popup menu item.
DFC_POPUPMENU = 5,
}
/// Flags used by .
[PInvokeData("winuser.h", MSDNShortId = "54a9234a-0056-4cfe-9158-86635dc31bc6")]
public enum IDANI
{
///
IDANI_OPEN = 1,
///
/// The window caption will animate from the position specified by lprcFrom to the position specified by lprcTo. The effect is
/// similar to minimizing or maximizing a window.
///
IDANI_CAPTION = 3
}
/// Flags used to invalidate or validate a window, control repainting, and control which windows are affected by RedrawWindow.
[PInvokeData("winuser.h", MSDNShortId = "c6cb7f74-237e-4d3e-a852-894da36e990c")]
[Flags]
public enum RedrawWindowFlags
{
/// Invalidates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is invalidated.
RDW_INVALIDATE = 0x0001,
/// Causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid.
RDW_INTERNALPAINT = 0x0002,
///
/// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. The RDW_INVALIDATE flag must also be
/// specified; otherwise, RDW_ERASE has no effect.
///
RDW_ERASE = 0x0004,
///
/// Validates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is validated. This flag
/// does not affect internal WM_PAINT messages.
///
RDW_VALIDATE = 0x0008,
///
/// Suppresses any pending internal WM_PAINT messages. This flag does not affect WM_PAINT messages resulting from a non-NULL
/// update area.
///
RDW_NOINTERNALPAINT = 0x0010,
/// Suppresses any pending WM_ERASEBKGND messages.
RDW_NOERASE = 0x0020,
/// Excludes child windows, if any, from the repainting operation.
RDW_NOCHILDREN = 0x0040,
/// Includes child windows, if any, in the repainting operation.
RDW_ALLCHILDREN = 0x0080,
///
/// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT,
/// WM_ERASEBKGND, and WM_PAINT messages, if necessary, before the function returns.
///
RDW_UPDATENOW = 0x0100,
///
/// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT and
/// WM_ERASEBKGND messages, if necessary, before the function returns. WM_PAINT messages are received at the ordinary time.
///
RDW_ERASENOW = 0x0200,
///
/// Causes any part of the nonclient area of the window that intersects the update region to receive a WM_NCPAINT message. The
/// RDW_INVALIDATE flag must also be specified; otherwise, RDW_FRAME has no effect. The WM_NCPAINT message is typically not sent
/// during the execution of RedrawWindow unless either RDW_UPDATENOW or RDW_ERASENOW is specified.
///
RDW_FRAME = 0x0400,
///
/// Suppresses any pending WM_NCPAINT messages. This flag must be used with RDW_VALIDATE and is typically used with
/// RDW_NOCHILDREN. RDW_NOFRAME should be used with care, as it could cause parts of a window to be painted improperly.
///
RDW_NOFRAME = 0x0800,
}
///
/// The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information
/// about the painting.
///
/// Handle to the window to be repainted.
/// Pointer to the PAINTSTRUCT structure that will receive painting information.
///
/// If the function succeeds, the return value is the handle to a display device context for the specified window.
/// If the function fails, the return value is NULL, indicating that no display device context is available.
///
///
///
/// The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the
/// update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving,
/// creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing,
/// BeginPaint sends a WM_ERASEBKGND message to the window.
///
///
/// An application should not call BeginPaint except in response to a WM_PAINT message. Each call to BeginPaint
/// must have a corresponding call to the EndPaint function.
///
/// If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased.
///
/// If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region
/// before returning.
///
/// DPI Virtualization
/// This API does not participate in DPI virtualization. The output returned is always in terms of physical pixels.
/// Examples
/// For an example, see Drawing in the Client Area.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-beginpaint HDC BeginPaint( HWND hWnd, LPPAINTSTRUCT
// lpPaint );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "513341d7-bed8-469c-a067-ee71dc8860f9")]
public static extern HDC BeginPaint(HWND hWnd, out PAINTSTRUCT lpPaint);
/// Animates the caption of a window to indicate the opening of an icon or the minimizing or maximizing of a window.
///
/// A handle to the window whose caption should be animated on the screen. The animation will be clipped to the parent of this window.
///
///
/// The type of animation. This must be IDANI_CAPTION. With the IDANI_CAPTION animation type, the window caption will animate from
/// the position specified by lprcFrom to the position specified by lprcTo. The effect is similar to minimizing or maximizing a window.
///
///
/// A pointer to a RECT structure specifying the location and size of the icon or minimized window. Coordinates are relative to the
/// clipping window hwnd.
///
///
/// A pointer to a RECT structure specifying the location and size of the restored window. Coordinates are relative to the clipping
/// window hwnd.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawanimatedrects BOOL DrawAnimatedRects( HWND hwnd, int
// idAni, const RECT *lprcFrom, const RECT *lprcTo );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "54a9234a-0056-4cfe-9158-86635dc31bc6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawAnimatedRects(HWND hwnd, IDANI idAni, in RECT lprcFrom, in RECT lprcTo);
/// The DrawCaption function draws a window caption.
/// A handle to a window that supplies text and an icon for the window caption.
/// A handle to a device context. The function draws the window caption into this device context.
///
/// A pointer to a RECT structure that specifies the bounding rectangle for the window caption in logical coordinates.
///
///
/// The drawing options. This parameter can be zero or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// DC_ACTIVE
/// The function uses the colors that denote an active caption.
///
/// -
/// DC_BUTTONS
/// If set, the function draws the buttons in the caption bar (to minimize, restore, or close an application).
///
/// -
/// DC_GRADIENT
///
/// When this flag is set, the function uses COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or
/// COLOR_GRADIENTINACTIVECAPTION for the title-bar color. If this flag is not set, the function uses COLOR_ACTIVECAPTION or
/// COLOR_INACTIVECAPTION for both colors.
///
///
/// -
/// DC_ICON
/// The function draws the icon when drawing the caption text.
///
/// -
/// DC_INBUTTON
/// The function draws the caption as a button.
///
/// -
/// DC_SMALLCAP
/// The function draws a small caption, using the current small caption font.
///
/// -
/// DC_TEXT
/// The function draws the caption text when drawing the caption.
///
///
/// If DC_SMALLCAP is specified, the function draws a normal window caption.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawcaption BOOL DrawCaption( HWND hwnd, HDC hdc, const
// RECT *lprect, UINT flags );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "9348e29f-ce56-4664-8862-f5810c797622")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawCaption(HWND hwnd, HDC hdc, in RECT lprect, DrawCaptionFlags flags);
/// The DrawEdge function draws one or more edges of rectangle.
/// A handle to the device context.
/// A pointer to a RECT structure that contains the logical coordinates of the rectangle.
///
///
/// The type of inner and outer edges to draw. This parameter must be a combination of one inner-border flag and one outer-border
/// flag. The inner-border flags are as follows.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// BDR_RAISEDINNER
/// Raised inner edge.
///
/// -
/// BDR_SUNKENINNER
/// Sunken inner edge.
///
///
///
/// The outer-border flags are as follows.
///
///
///
/// Value
/// Meaning
///
/// -
/// BDR_RAISEDOUTER
/// Raised outer edge.
///
/// -
/// BDR_SUNKENOUTER
/// Sunken outer edge.
///
///
///
/// Alternatively, the edge parameter can specify one of the following flags.
///
///
///
/// Value
/// Meaning
///
/// -
/// EDGE_BUMP
/// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER.
///
/// -
/// EDGE_ETCHED
/// Combination of BDR_SUNKENOUTER and BDR_RAISEDINNER.
///
/// -
/// EDGE_RAISED
/// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER.
///
/// -
/// EDGE_SUNKEN
/// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER.
///
///
///
///
///
/// The type of border. This parameter can be a combination of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// BF_ADJUST
///
/// If this flag is passed, shrink the rectangle pointed to by the qrc parameter to exclude the edges that were drawn.If this flag is
/// not passed, then do not change the rectangle pointed to by the qrc parameter.
///
///
/// -
/// BF_BOTTOM
/// Bottom of border rectangle.
///
/// -
/// BF_BOTTOMLEFT
/// Bottom and left side of border rectangle.
///
/// -
/// BF_BOTTOMRIGHT
/// Bottom and right side of border rectangle.
///
/// -
/// BF_DIAGONAL
/// Diagonal border.
///
/// -
/// BF_DIAGONAL_ENDBOTTOMLEFT
/// Diagonal border. The end point is the lower-left corner of the rectangle; the origin is top-right corner.
///
/// -
/// BF_DIAGONAL_ENDBOTTOMRIGHT
/// Diagonal border. The end point is the lower-right corner of the rectangle; the origin is top-left corner.
///
/// -
/// BF_DIAGONAL_ENDTOPLEFT
/// Diagonal border. The end point is the top-left corner of the rectangle; the origin is lower-right corner.
///
/// -
/// BF_DIAGONAL_ENDTOPRIGHT
/// Diagonal border. The end point is the top-right corner of the rectangle; the origin is lower-left corner.
///
/// -
/// BF_FLAT
/// Flat border.
///
/// -
/// BF_LEFT
/// Left side of border rectangle.
///
/// -
/// BF_MIDDLE
/// Interior of rectangle to be filled.
///
/// -
/// BF_MONO
/// One-dimensional border.
///
/// -
/// BF_RECT
/// Entire border rectangle.
///
/// -
/// BF_RIGHT
/// Right side of border rectangle.
///
/// -
/// BF_SOFT
/// Soft buttons instead of tiles.
///
/// -
/// BF_TOP
/// Top of border rectangle.
///
/// -
/// BF_TOPLEFT
/// Top and left side of border rectangle.
///
/// -
/// BF_TOPRIGHT
/// Top and right side of border rectangle.
///
///
///
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// BOOL DrawEdge( _In_ HDC hdc, _Inout_ LPRECT qrc, _In_ UINT edge, _In_ UINT grfFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/dd162477(v=vs.85).aspx
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Winuser.h", MSDNShortId = "dd162477")]
public static extern bool DrawEdge(HDC hdc, ref RECT qrc, BorderStyles3D edge, BorderFlags grfFlags);
/// The DrawFocusRect function draws a rectangle in the style used to indicate that the rectangle has the focus.
/// A handle to the device context.
/// A pointer to a RECT structure that specifies the logical coordinates of the rectangle.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// DrawFocusRect works only in MM_TEXT mode.
///
/// Because DrawFocusRect is an XOR function, calling it a second time with the same rectangle removes the rectangle from the screen.
///
///
/// This function draws a rectangle that cannot be scrolled. To scroll an area containing a rectangle drawn by this function, call
/// DrawFocusRect to remove the rectangle from the screen, scroll the area, and then call DrawFocusRect again to draw
/// the rectangle in the new position.
///
///
/// Windows XP: The focus rectangle can now be thicker than 1 pixel, so it is more visible for high-resolution, high-density
/// displays and accessibility needs. This is handled by the SPI_SETFOCUSBORDERWIDTH and SPI_SETFOCUSBORDERHEIGHT in SystemParametersInfo.
///
/// Examples
/// For an example, see "Creating an Owner-Drawn List Box" in Using List Boxes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawfocusrect BOOL DrawFocusRect( HDC hDC, const RECT
// *lprc );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "a910d04f-fe4d-4fc9-a518-abac864da6f3")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawFocusRect(HDC hDC, in RECT lprc);
/// The DrawFrameControl function draws a frame control of the specified type and style.
/// Handle to the device context of the window in which to draw the control.
///
/// Long pointer to a RECT structure that contains the logical coordinates of the bounding rectangle for frame control.
///
/// Specifies the type of frame control to draw.
/// Specifies the initial state of the frame control.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// If uType is either DFC_MENU or DFC_BUTTON and uState is not DFCS_BUTTONPUSH, the frame control is a black-on-white mask (that is,
/// a black frame control on a white background). In such cases, the application must pass a handle to a bitmap memory device
/// control. The application can then use the associated bitmap as the hbmMask parameter to the MaskBlt function, or it can use the
/// device context as a parameter to the BitBlt function using ROPs such as SRCAND and SRCINVERT.
///
/// DPI Virtualization
///
/// This API does not participate in DPI virtualization. The input given is always in terms of physical pixels, and is not related to
/// the calling context.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawframecontrol BOOL DrawFrameControl( HDC , LPRECT ,
// UINT , UINT );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawFrameControl(HDC hdc, in RECT lprc, FrameControlType uType, FrameControlState uState);
///
/// The DrawState function displays an image and applies a visual effect to indicate a state, such as a disabled or default state.
///
/// A handle to the device context to draw in.
///
/// A handle to the brush used to draw the image, if the state specified by the fuFlags parameter is DSS_MONO. This parameter is
/// ignored for other states.
///
///
/// A pointer to an application-defined callback function used to render the image. This parameter is required if the image type in
/// fuFlags is DST_COMPLEX. It is optional and can be NULL if the image type is DST_TEXT. For all other image types, this
/// parameter is ignored. For more information about the callback function, see the DrawStateProc function.
///
/// Information about the image. The meaning of this parameter depends on the image type.
///
/// Information about the image. The meaning of this parameter depends on the image type. It is, however, zero extended for use with
/// the DrawStateProc function.
///
/// The horizontal location, in device units, at which to draw the image.
/// The vertical location, in device units, at which to draw the image.
///
/// The width of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero
/// to calculate the width of the image.
///
///
/// The height of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero
/// to calculate the height of the image.
///
///
/// The image type and state. This parameter can be one of the following type values.
///
///
/// Value (type)
/// Meaning
///
/// -
/// DST_BITMAP
///
/// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an existing
/// device context.
///
///
/// -
/// DST_COMPLEX
///
/// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter.
///
///
/// -
/// DST_ICON
/// The image is an icon. The lData parameter is the icon handle.
///
/// -
/// DST_PREFIXTEXT
///
/// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character as a
/// directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData parameter
/// specifies the length. If wData is zero, the string must be null-terminated.
///
///
/// -
/// DST_TEXT
///
/// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is
/// zero, the string must be null-terminated.
///
///
///
/// This parameter can also be one of the following state values.
///
///
/// Value (state)
/// Meaning
///
/// -
/// DSS_DISABLED
/// Embosses the image.
///
/// -
/// DSS_HIDEPREFIX
///
/// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This must be
/// used with DST_PREFIXTEXT.
///
///
/// -
/// DSS_MONO
/// Draws the image using the brush specified by the hbr parameter.
///
/// -
/// DSS_NORMAL
/// Draws the image without any modification.
///
/// -
/// DSS_PREFIXONLY
///
/// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the string is
/// drawn. This must be used with DST_PREFIXTEXT.
///
///
/// -
/// DSS_RIGHT
/// Aligns the text to the right.
///
/// -
/// DSS_UNION
/// Dithers the image.
///
///
/// For all states except DSS_NORMAL, the image is converted to monochrome before the visual effect is applied.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawstatea BOOL DrawStateA( HDC hdc, HBRUSH hbrFore,
// DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, int x, int y, int cx, int cy, UINT uFlags );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, IntPtr lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags);
///
/// The DrawState function displays an image and applies a visual effect to indicate a state, such as a disabled or default state.
///
/// A handle to the device context to draw in.
///
/// A handle to the brush used to draw the image, if the state specified by the fuFlags parameter is DSS_MONO. This parameter is
/// ignored for other states.
///
///
/// A pointer to an application-defined callback function used to render the image. This parameter is required if the image type in
/// fuFlags is DST_COMPLEX. It is optional and can be NULL if the image type is DST_TEXT. For all other image types, this
/// parameter is ignored. For more information about the callback function, see the DrawStateProc function.
///
/// Information about the image. The meaning of this parameter depends on the image type.
///
/// Information about the image. The meaning of this parameter depends on the image type. It is, however, zero extended for use with
/// the DrawStateProc function.
///
/// The horizontal location, in device units, at which to draw the image.
/// The vertical location, in device units, at which to draw the image.
///
/// The width of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero
/// to calculate the width of the image.
///
///
/// The height of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero
/// to calculate the height of the image.
///
///
/// The image type and state. This parameter can be one of the following type values.
///
///
/// Value (type)
/// Meaning
///
/// -
/// DST_BITMAP
///
/// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an existing
/// device context.
///
///
/// -
/// DST_COMPLEX
///
/// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter.
///
///
/// -
/// DST_ICON
/// The image is an icon. The lData parameter is the icon handle.
///
/// -
/// DST_PREFIXTEXT
///
/// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character as a
/// directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData parameter
/// specifies the length. If wData is zero, the string must be null-terminated.
///
///
/// -
/// DST_TEXT
///
/// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is
/// zero, the string must be null-terminated.
///
///
///
/// This parameter can also be one of the following state values.
///
///
/// Value (state)
/// Meaning
///
/// -
/// DSS_DISABLED
/// Embosses the image.
///
/// -
/// DSS_HIDEPREFIX
///
/// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This must be
/// used with DST_PREFIXTEXT.
///
///
/// -
/// DSS_MONO
/// Draws the image using the brush specified by the hbr parameter.
///
/// -
/// DSS_NORMAL
/// Draws the image without any modification.
///
/// -
/// DSS_PREFIXONLY
///
/// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the string is
/// drawn. This must be used with DST_PREFIXTEXT.
///
///
/// -
/// DSS_RIGHT
/// Aligns the text to the right.
///
/// -
/// DSS_UNION
/// Dithers the image.
///
///
/// For all states except DSS_NORMAL, the image is converted to monochrome before the visual effect is applied.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawstatea BOOL DrawStateA( HDC hdc, HBRUSH hbrFore,
// DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, int x, int y, int cx, int cy, UINT uFlags );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, string lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags);
///
/// The EndPaint function marks the end of painting in the specified window. This function is required for each call to the
/// BeginPaint function, but only after painting is complete.
///
/// Handle to the window that has been repainted.
/// Pointer to a PAINTSTRUCT structure that contains the painting information retrieved by BeginPaint.
/// The return value is always nonzero.
///
/// If the caret was hidden by BeginPaint, EndPaint restores the caret to the screen.
/// EndPaint releases the display device context that BeginPaint retrieved.
/// Examples
/// For an example, see Drawing in the Client Area.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-endpaint BOOL EndPaint( HWND hWnd, const PAINTSTRUCT
// *lpPaint );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "b07cfed9-21c4-4459-855a-eaf4d1d34ab8")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EndPaint(HWND hWnd, in PAINTSTRUCT lpPaint);
///
/// The ExcludeUpdateRgn function prevents drawing within invalid areas of a window by excluding an updated region in the
/// window from a clipping region.
///
/// Handle to the device context associated with the clipping region.
/// Handle to the window to update.
///
/// The return value specifies the complexity of the excluded region; it can be any one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// COMPLEXREGION
/// Region consists of more than one rectangle.
///
/// -
/// ERROR
/// An error occurred.
///
/// -
/// NULLREGION
/// Region is empty.
///
/// -
/// SIMPLEREGION
/// Region is a single rectangle.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-excludeupdatergn int ExcludeUpdateRgn( HDC hDC, HWND hWnd );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "408fda82-30c3-4eb4-be42-3085c71ba99e")]
public static extern Gdi32.RegionFlags ExcludeUpdateRgn(HDC hDC, HWND hWnd);
///
/// The FillRect function fills a rectangle by using the specified brush. This function includes the left and top borders, but
/// excludes the right and bottom borders of the rectangle.
///
/// A handle to the device context.
/// A pointer to a RECT structure that contains the logical coordinates of the rectangle to be filled.
/// A handle to the brush used to fill the rectangle.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The brush identified by the hbr parameter may be either a handle to a logical brush or a color value. If specifying a handle to a
/// logical brush, call one of the following functions to obtain the handle: CreateHatchBrush, CreatePatternBrush, or
/// CreateSolidBrush. Additionally, you may retrieve a handle to one of the stock brushes by using the GetStockObject function. If
/// specifying a color value for the hbr parameter, it must be one of the standard system colors (the value 1 must be added to the
/// chosen color). For example:
///
/// For a list of all the standard system colors, see GetSysColor.
///
/// When filling the specified rectangle, FillRect does not include the rectangle's right and bottom sides. GDI fills a
/// rectangle up to, but not including, the right column and bottom row, regardless of the current mapping mode.
///
/// Examples
/// For an example, see Using Rectangles.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-fillrect int FillRect( HDC hDC, const RECT *lprc, HBRUSH
// hbr );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "98ab34da-ea07-4446-a62e-509c849d95f9")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FillRect(HDC hDC, in RECT lprc, HBRUSH hbr);
///
/// The FrameRect function draws a border around the specified rectangle by using the specified brush. The width and height of
/// the border are always one logical unit.
///
/// A handle to the device context in which the border is drawn.
///
/// A pointer to a RECT structure that contains the logical coordinates of the upper-left and lower-right corners of the rectangle.
///
/// A handle to the brush used to draw the border.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The brush identified by the hbr parameter must have been created by using the CreateHatchBrush, CreatePatternBrush, or
/// CreateSolidBrush function, or retrieved by using the GetStockObject function.
///
///
/// If the bottom member of the RECT structure is less than the top member, or if the right member is less than
/// the left member, the function does not draw the rectangle.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-framerect int FrameRect( HDC hDC, const RECT *lprc, HBRUSH
// hbr );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "a1083cb5-5e6c-4134-badf-9fc5142d1453")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FrameRect(HDC hDC, in RECT lprc, HBRUSH hbr);
///
/// The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely encloses the update region
/// of the specified window. GetUpdateRect retrieves the rectangle in logical coordinates. If there is no update region,
/// GetUpdateRect retrieves an empty rectangle (sets all coordinates to zero).
///
/// Handle to the window whose update region is to be retrieved.
///
/// Pointer to the RECT structure that receives the coordinates, in device units, of the enclosing rectangle.
///
/// An application can set this parameter to NULL to determine whether an update region exists for the window. If this
/// parameter is NULL, GetUpdateRect returns nonzero if an update region exists, and zero if one does not. This
/// provides a simple and efficient means of determining whether a WM_PAINT message resulted from an invalid area.
///
///
///
/// Specifies whether the background in the update region is to be erased. If this parameter is TRUE and the update region is
/// not empty, GetUpdateRect sends a WM_ERASEBKGND message to the specified window to erase the background.
///
///
/// If the update region is not empty, the return value is nonzero.
/// If there is no update region, the return value is zero.
///
///
/// The update rectangle retrieved by the BeginPaint function is identical to that retrieved by GetUpdateRect.
///
/// BeginPaint automatically validates the update region, so any call to GetUpdateRect made immediately after the call to
/// BeginPaint retrieves an empty update region.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getupdaterect BOOL GetUpdateRect( HWND hWnd, LPRECT
// lpRect, BOOL bErase );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "e54483a1-8738-4b22-a24e-c0b31f6ca9d6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetUpdateRect(HWND hWnd, PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
///
/// The GetUpdateRgn function retrieves the update region of a window by copying it into the specified region. The coordinates
/// of the update region are relative to the upper-left corner of the window (that is, they are client coordinates).
///
/// Handle to the window with an update region that is to be retrieved.
/// Handle to the region to receive the update region.
///
/// Specifies whether the window background should be erased and whether nonclient areas of child windows should be drawn. If this
/// parameter is FALSE, no drawing is done.
///
///
/// The return value indicates the complexity of the resulting region; it can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// COMPLEXREGION
/// Region consists of more than one rectangle.
///
/// -
/// ERROR
/// An error occurred.
///
/// -
/// NULLREGION
/// Region is empty.
///
/// -
/// SIMPLEREGION
/// Region is a single rectangle.
///
///
///
///
/// The BeginPaint function automatically validates the update region, so any call to GetUpdateRgn made immediately after the
/// call to BeginPaint retrieves an empty update region.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getupdatergn int GetUpdateRgn( HWND hWnd, HRGN hRgn, BOOL
// bErase );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "d80c4b44-3f50-46f9-bf5a-fff7868d91ba")]
public static extern Gdi32.RegionFlags GetUpdateRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase);
///
///
/// The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll
/// bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left
/// corner of the window instead of the client area.
///
///
/// GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous
/// attributes are lost.
///
///
///
///
/// A handle to the window with a device context that is to be retrieved. If this value is NULL, GetWindowDC retrieves
/// the device context for the entire screen.
///
///
/// If this parameter is NULL, GetWindowDC retrieves the device context for the primary display monitor. To get the
/// device context for other display monitors, use the EnumDisplayMonitors and CreateDC functions.
///
///
///
/// If the function succeeds, the return value is a handle to a device context for the specified window.
/// If the function fails, the return value is NULL, indicating an error or an invalid hWnd parameter.
///
///
///
/// GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any
/// window is not recommended.
///
///
/// The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title
/// bar, menu, and scroll bars.
///
/// The GetDC function can be used to retrieve a device context for the entire screen.
///
/// After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device
/// context has serious effects on painting requested by applications.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowdc HDC GetWindowDC( HWND hWnd );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "9e6a135e-e337-4129-a3ad-faf9a8ac9b2d")]
public static extern HDC GetWindowDC(HWND hWnd);
///
/// The GetWindowRgn function obtains a copy of the window region of a window. The window region of a window is set by calling
/// the SetWindowRgn function. The window region determines the area within the window where the system permits drawing. The system
/// does not display any portion of a window that lies outside of the window region
///
/// Handle to the window whose window region is to be obtained.
/// Handle to the region which will be modified to represent the window region.
///
/// The return value specifies the type of the region that the function obtains. It can be one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// NULLREGION
/// The region is empty.
///
/// -
/// SIMPLEREGION
/// The region is a single rectangle.
///
/// -
/// COMPLEXREGION
/// The region is more than one rectangle.
///
/// -
/// ERROR
/// The specified window does not have a region, or an error occurred while attempting to return the region.
///
///
///
///
///
/// The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.
///
/// To set the window region of a window, call the SetWindowRgn function.
/// Examples
/// The following code shows how you pass in the handle of an existing region.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowrgn int GetWindowRgn( HWND hWnd, HRGN hRgn );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "c8a8fa46-354b-489e-b016-fd2e728958ce")]
public static extern Gdi32.RegionFlags GetWindowRgn(HWND hWnd, HRGN hRgn);
///
/// The GetWindowRgnBox function retrieves the dimensions of the tightest bounding rectangle for the window region of a window.
///
/// Handle to the window.
///
/// Pointer to a RECT structure that receives the rectangle dimensions, in device units relative to the upper-left corner of the window.
///
///
/// The return value specifies the type of the region that the function obtains. It can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// COMPLEXREGION
/// The region is more than one rectangle.
///
/// -
/// ERROR
/// The specified window does not have a region, or an error occurred while attempting to return the region.
///
/// -
/// NULLREGION
/// The region is empty.
///
/// -
/// SIMPLEREGION
/// The region is a single rectangle.
///
///
///
///
///
/// The window region determines the area within the window where the system permits drawing. The system does not display any portion
/// of a window that lies outside of the window region. The coordinates of a window's window region are relative to the upper-left
/// corner of the window, not the client area of the window.
///
/// To set the window region of a window, call the SetWindowRgn function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowrgnbox int GetWindowRgnBox( HWND hWnd, LPRECT
// lprc );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "20e23474-a1c5-4afe-976e-a7e5790fb91b")]
public static extern Gdi32.RegionFlags GetWindowRgnBox(HWND hWnd, out RECT lprc);
///
///
/// The GrayString function draws gray text at the specified location. The function draws the text by copying it into a memory
/// bitmap, graying the bitmap, and then copying the bitmap to the screen. The function grays the text regardless of the selected
/// brush and background. GrayString uses the font currently selected for the specified device context.
///
///
/// If thelpOutputFuncparameter is NULL, GDI uses the TextOut function, and thelpDataparameter is assumed to be a pointer to
/// the character string to be output. If the characters to be output cannot be handled by TextOut (for example, the string is
/// stored as a bitmap), the application must supply its own output function.
///
///
/// A handle to the device context.
///
/// A handle to the brush to be used for graying. If this parameter is NULL, the text is grayed with the same brush that was
/// used to draw window text.
///
///
/// A pointer to the application-defined function that will draw the string, or, if TextOut is to be used to draw the string, it is a
/// NULL pointer. For details, see the OutputProc callback function.
///
///
/// A pointer to data to be passed to the output function. If the lpOutputFunc parameter is NULL, lpData must be a pointer to
/// the string to be output.
///
///
/// The number of characters to be output. If the nCount parameter is zero, GrayString calculates the length of the string
/// (assuming lpData is a pointer to the string). If nCount is 1 and the function pointed to by lpOutputFunc returns FALSE,
/// the image is shown but not grayed.
///
/// The device x-coordinate of the starting position of the rectangle that encloses the string.
/// The device y-coordinate of the starting position of the rectangle that encloses the string.
///
/// The width, in device units, of the rectangle that encloses the string. If this parameter is zero, GrayString calculates
/// the width of the area, assuming lpData is a pointer to the string.
///
///
/// The height, in device units, of the rectangle that encloses the string. If this parameter is zero, GrayString calculates
/// the height of the area, assuming lpData is a pointer to the string.
///
///
/// If the string is drawn, the return value is nonzero.
///
/// If either the TextOut function or the application-defined output function returned zero, or there was insufficient memory to
/// create a memory bitmap for graying, the return value is zero.
///
///
///
/// Without calling GrayString, an application can draw grayed strings on devices that support a solid gray color. The system
/// color COLOR_GRAYTEXT is the solid-gray system color used to draw disabled text. The application can call the GetSysColor function
/// to retrieve the color value of COLOR_GRAYTEXT. If the color is other than zero (black), the application can call the SetTextColor
/// function to set the text color to the color value and then draw the string directly. If the retrieved color is black, the
/// application must call GrayString to gray the text.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-graystringa BOOL GrayStringA( HDC hDC, HBRUSH hBrush,
// GRAYSTRINGPROC lpOutputFunc, LPARAM lpData, int nCount, int X, int Y, int nWidth, int nHeight );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b14b8c40-f97f-4e41-8d8d-687692acfda9")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GrayString(HDC hDC, HBRUSH hBrush, OutputProc lpOutputFunc, string lpData, int nCount, int X, int Y, int nWidth, int nHeight);
///
/// 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.
///
///
/// A handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all
/// windows, not just the windows for this application, and sends the WM_ERASEBKGND and WM_NCPAINT messages before the function
/// returns. Setting this parameter to NULL is not recommended.
///
///
/// A 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.
///
///
/// 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.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// 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.
///
/// Examples
/// For an example, see Invalidating the Client Area.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-invalidaterect BOOL InvalidateRect( HWND hWnd, const RECT
// *lpRect, BOOL bErase );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "5a823d36-d08b-41c9-8857-540576f54b55")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InvalidateRect(HWND hWnd, [In] PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
///
/// The InvalidateRgn function invalidates the client area within the specified region by adding it to the current update
/// region of a window. The invalidated region, along with all other areas in the update region, is marked for painting when the next
/// WM_PAINT message occurs.
///
/// A handle to the window with an update region that is to be modified.
///
/// A handle to the region to be added to the update region. The region is assumed to have client coordinates. If this parameter is
/// NULL, the entire client area is added to the update region.
///
///
/// Specifies whether the background within the update region should be erased when the update region is processed. If this parameter
/// is TRUE, the background is erased when the BeginPaint function is called. If the parameter is FALSE, the background
/// remains unchanged.
///
/// The return value is always nonzero.
///
///
/// Invalidated areas accumulate in the update region until the next WM_PAINT message is processed 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.
///
/// The specified region must have been created by using one of the region functions.
///
/// If the bErase parameter is TRUE for any part of the update region, the background in the entire region is erased, not just
/// in the specified part.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-invalidatergn BOOL InvalidateRgn( HWND hWnd, HRGN hRgn,
// BOOL bErase );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "b5b44efe-8045-4e54-89f9-1766689a053d")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InvalidateRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase);
///
/// The LockWindowUpdate function disables or enables drawing in the specified window. Only one window can be locked at a time.
///
///
/// The window in which drawing will be disabled. If this parameter is NULL, drawing in the locked window is enabled.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero, indicating that an error occurred or another window was already locked.
///
///
///
/// The purpose of the LockWindowUpdate function is to permit drag/drop feedback to be drawn over a window without
/// interference from the window itself. The intent is that the window is locked when feedback is drawn and unlocked when feedback is
/// complete. LockWindowUpdate is not intended for general-purpose suppression of window redraw. Use the WM_SETREDRAW message
/// to disable redrawing of a particular window.
///
///
/// If an application with a locked window (or any locked child windows) calls the GetDC, GetDCEx, or BeginPaint function, the called
/// function returns a device context with a visible region that is empty. This will occur until the application unlocks the window
/// by calling LockWindowUpdate, specifying a value of NULL for hWndLock.
///
///
/// If an application attempts to draw within a locked window, the system records the extent of the attempted operation in a bounding
/// rectangle. When the window is unlocked, the system invalidates the area within this bounding rectangle, forcing an eventual
/// WM_PAINT message to be sent to the previously locked window and its child windows. If no drawing has occurred while the window
/// updates were locked, no area is invalidated.
///
/// LockWindowUpdate does not make the specified window invisible and does not clear the WS_VISIBLE style bit.
/// A locked window cannot be moved.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-lockwindowupdate BOOL LockWindowUpdate( HWND hWndLock );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "00ec40c7-8ab2-40db-a9bb-48e18d66bf1a")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LockWindowUpdate(HWND hWndLock);
///
/// The PaintDesktop function fills the clipping region in the specified device context with the desktop pattern or wallpaper.
/// The function is provided primarily for shell desktops.
///
/// Handle to the device context.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-paintdesktop BOOL PaintDesktop( HDC hdc );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "738500d4-32f5-43cf-8d40-9ad201ca6d4b")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PaintDesktop(HDC hdc);
/// The RedrawWindow function updates the specified rectangle or region in a window's client area.
/// A handle to the window to be redrawn. If this parameter is NULL, the desktop window is updated.
///
/// A pointer to a RECT structure containing the coordinates, in device units, of the update rectangle. This parameter is ignored if
/// the hrgnUpdate parameter identifies a region.
///
///
/// A handle to the update region. If both the hrgnUpdate and lprcUpdate parameters are NULL, the entire client area is added
/// to the update region.
///
///
///
/// One or more redraw flags. This parameter can be used to invalidate or validate a window, control repainting, and control which
/// windows are affected by RedrawWindow.
///
/// The following flags are used to invalidate the window.
///
///
/// Flag (invalidation)
/// Description
///
/// -
/// RDW_ERASE
///
/// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. The RDW_INVALIDATE flag must also be
/// specified; otherwise, RDW_ERASE has no effect.
///
///
/// -
/// RDW_FRAME
///
/// Causes any part of the nonclient area of the window that intersects the update region to receive a WM_NCPAINT message. The
/// RDW_INVALIDATE flag must also be specified; otherwise, RDW_FRAME has no effect. The WM_NCPAINT message is typically not sent
/// during the execution of RedrawWindow unless either RDW_UPDATENOW or RDW_ERASENOW is specified.
///
///
/// -
/// RDW_INTERNALPAINT
/// Causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid.
///
/// -
/// RDW_INVALIDATE
/// Invalidates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is invalidated.
///
///
/// The following flags are used to validate the window.
///
///
/// Flag (validation)
/// Description
///
/// -
/// RDW_NOERASE
/// Suppresses any pending WM_ERASEBKGND messages.
///
/// -
/// RDW_NOFRAME
///
/// Suppresses any pending WM_NCPAINT messages. This flag must be used with RDW_VALIDATE and is typically used with RDW_NOCHILDREN.
/// RDW_NOFRAME should be used with care, as it could cause parts of a window to be painted improperly.
///
///
/// -
/// RDW_NOINTERNALPAINT
///
/// Suppresses any pending internal WM_PAINT messages. This flag does not affect WM_PAINT messages resulting from a non-NULL update area.
///
///
/// -
/// RDW_VALIDATE
///
/// Validates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is validated. This flag does
/// not affect internal WM_PAINT messages.
///
///
///
///
/// The following flags control when repainting occurs. RedrawWindow will not repaint unless one of these flags is specified.
///
///
///
/// Flag
/// Description
///
/// -
/// RDW_ERASENOW
///
/// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT and
/// WM_ERASEBKGND messages, if necessary, before the function returns. WM_PAINT messages are received at the ordinary time.
///
///
/// -
/// RDW_UPDATENOW
///
/// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT, WM_ERASEBKGND,
/// and WM_PAINT messages, if necessary, before the function returns.
///
///
///
///
/// By default, the windows affected by RedrawWindow depend on whether the specified window has the WS_CLIPCHILDREN style.
/// Child windows that are not the WS_CLIPCHILDREN style are unaffected; non-WS_CLIPCHILDREN windows are recursively validated or
/// invalidated until a WS_CLIPCHILDREN window is encountered. The following flags control which windows are affected by the
/// RedrawWindow function.
///
///
///
/// Flag
/// Description
///
/// -
/// RDW_ALLCHILDREN
/// Includes child windows, if any, in the repainting operation.
///
/// -
/// RDW_NOCHILDREN
/// Excludes child windows, if any, from the repainting operation.
///
///
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// When RedrawWindow is used to invalidate part of the desktop window, the desktop window does not receive a WM_PAINT
/// message. To repaint the desktop, an application uses the RDW_ERASE flag to generate a WM_ERASEBKGND message.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-redrawwindow BOOL RedrawWindow( HWND hWnd, const RECT
// *lprcUpdate, HRGN hrgnUpdate, UINT flags );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "c6cb7f74-237e-4d3e-a852-894da36e990c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RedrawWindow(HWND hWnd, [In] PRECT lprcUpdate, HRGN hrgnUpdate, RedrawWindowFlags flags);
///
/// The SetWindowRgn function sets the window region of a window. The window region determines the area within the window
/// where the system permits drawing. The system does not display any portion of a window that lies outside of the window region
///
/// A handle to the window whose window region is to be set.
///
/// A handle to a region. The function sets the window region of the window to this region.
/// If hRgn is NULL, the function sets the window region to NULL.
///
///
///
/// Specifies whether the system redraws the window after setting the window region. If bRedraw is TRUE, the system does so;
/// otherwise, it does not.
///
/// Typically, you set bRedraw to TRUE if the window is visible.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// When this function is called, the system sends the WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGING messages to the window.
///
///
/// The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.
///
///
/// Note If the window layout is right-to-left (RTL), the coordinates are relative to the upper-right corner of the window.
/// See Window Layout and Mirroring.
///
///
/// After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does
/// not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do
/// not delete this region handle. The system deletes the region handle when it no longer needed.
///
/// To obtain the window region of a window, call the GetWindowRgn function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowrgn int SetWindowRgn( HWND hWnd, HRGN hRgn, BOOL
// bRedraw );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "06209d0c-14f9-45ec-ae2c-9cc596b5bbaa")]
public static extern int SetWindowRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
///
/// The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if
/// the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the
/// specified window, bypassing the application queue. If the update region is empty, no message is sent.
///
/// Handle to the window to be updated.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-updatewindow BOOL UpdateWindow( HWND hWnd );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "51a50f1f-7b4d-4acd-83a0-1877f5181766")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UpdateWindow(HWND hWnd);
///
/// The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of
/// the specified window.
///
///
/// Handle to the window whose update region is to be modified. 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.
///
///
/// Pointer to a RECT structure that contains the client coordinates of the rectangle to be removed from the update region. If this
/// parameter is NULL, the entire client area is removed.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRgn function
/// should be called if a portion of the update region must be validated before the next WM_PAINT message is generated.
///
/// The system continues to generate WM_PAINT messages until the current update region is validated.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-validaterect BOOL ValidateRect( HWND hWnd, const RECT
// *lpRect );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "961dd768-1849-44df-bc7f-480881ed6477")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ValidateRect(HWND hWnd, [In] PRECT lpRect);
///
/// The ValidateRgn function validates the client area within a region by removing the region from the current update region
/// of the specified window.
///
/// Handle to the window whose update region is to be modified.
///
/// Handle to a region that defines the area to be removed from the update region. If this parameter is NULL, the entire
/// client area is removed.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// The specified region must have been created by a region function. The region coordinates are assumed to be client coordinates.
///
/// The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRgn function
/// should be called if a portion of the update region must be validated before the next WM_PAINT message is generated.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-validatergn BOOL ValidateRgn( HWND hWnd, HRGN hRgn );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "80fb1d4a-d9b1-4e67-b585-eee81893ed34")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ValidateRgn(HWND hWnd, HRGN hRgn);
///
///
/// The PAINTSTRUCT structure contains information for an application. This information can be used to paint the client area
/// of a window owned by that application.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagpaintstruct typedef struct tagPAINTSTRUCT { HDC hdc;
// BOOL fErase; RECT rcPaint; BOOL fRestore; BOOL fIncUpdate; BYTE rgbReserved[32]; } PAINTSTRUCT, *PPAINTSTRUCT, *NPPAINTSTRUCT, *LPPAINTSTRUCT;
[PInvokeData("winuser.h", MSDNShortId = "1f8c6dd2-e511-48f2-8ab0-d2fadb1ce433")]
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
///
/// A handle to the display DC to be used for painting.
///
public HDC hdc;
///
///
/// Indicates whether the background must be erased. This value is nonzero if the application should erase the background. The
/// application is responsible for erasing the background if a window class is created without a background brush. For more
/// information, see the description of the hbrBackground member of the WNDCLASS structure.
///
///
[MarshalAs(UnmanagedType.Bool)]
public bool fErase;
///
///
/// A RECT structure that specifies the upper left and lower right corners of the rectangle in which the painting is requested,
/// in device units relative to the upper-left corner of the client area.
///
///
public RECT rcPaint;
///
/// Reserved; used internally by the system.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fRestore;
///
/// Reserved; used internally by the system.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fIncUpdate;
///
/// Reserved; used internally by the system.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] rgbReserved;
}
}
}