using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Gdi32 { /// The background mode used by the function. [PInvokeData("Wingdi.h", MSDNShortId = "dd162965")] public enum BackgroundMode { /// Indicates that on return, the has failed. ERROR = 0, /// Background remains untouched. TRANSPARENT = 1, /// Background is filled with the current background color before the text, hatched brush, or pen is drawn. OPAQUE = 2, } /// Bounds information. [PInvokeData("wingdi.h", MSDNShortId = "139d4550-9adc-48b3-a15c-03ae1f1ef1ab")] [Flags] public enum DCB { /// The bounding rectangle is empty. DCB_RESET = 0x0001, /// /// Adds the rectangle specified by the lprcBounds parameter to the bounding rectangle (using a rectangle union operation). Using /// both DCB_RESET and DCB_ACCUMULATE sets the bounding rectangle to the rectangle specified by the lprcBounds parameter. /// DCB_ACCUMULATE = 0x0002, /// Same as DCB_ACCUMULATE. DCB_DIRTY = DCB_ACCUMULATE, /// The bounding rectangle is not empty. DCB_SET = DCB_RESET | DCB_ACCUMULATE, /// Boundary accumulation is on. DCB_ENABLE = 0x0004, /// Boundary accumulation is off. DCB_DISABLE = 0x0008, } /// Foreground mix mode. [PInvokeData("wingdi.h", MSDNShortId = "ca1930e0-f6f4-44c8-979c-f50881f3c225")] public enum R2 { /// Pixel is always 0. R2_BLACK = 1, /// Pixel is the inverse of the R2_MERGEPEN color. R2_NOTMERGEPEN = 2, /// Pixel is a combination of the colors common to both the screen and the inverse of the pen. R2_MASKNOTPEN = 3, /// Pixel is the inverse of the pen color. R2_NOTCOPYPEN = 4, /// Pixel is a combination of the colors common to both the pen and the inverse of the screen. R2_MASKPENNOT = 5, /// Pixel is the inverse of the screen color. R2_NOT = 6, /// Pixel is a combination of the colors in the pen and in the screen, but not in both. R2_XORPEN = 7, /// Pixel is the inverse of the R2_MASKPEN color. R2_NOTMASKPEN = 8, /// Pixel is a combination of the colors common to both the pen and the screen. R2_MASKPEN = 9, /// Pixel is the inverse of the R2_XORPEN color. R2_NOTXORPEN = 10, /// Pixel remains unchanged. R2_NOP = 11, /// Pixel is a combination of the screen color and the inverse of the pen color. R2_MERGENOTPEN = 12, /// Pixel is the pen color. R2_COPYPEN = 13, /// Pixel is a combination of the pen color and the inverse of the screen color. R2_MERGEPENNOT = 14, /// Pixel is a combination of the pen color and the screen color. R2_MERGEPEN = 15, /// Pixel is always 1. R2_WHITE = 16 } /// The GdiFlush function flushes the calling thread's current batch. /// /// If all functions in the current batch succeed, the return value is nonzero. /// /// If not all functions in the current batch succeed, the return value is zero, indicating that at least one function returned an error. /// /// /// /// /// Batching enhances drawing performance by minimizing the amount of time needed to call GDI drawing functions that return Boolean /// values. The system accumulates the parameters for calls to these functions in the current batch and then calls the functions when /// the batch is flushed by any of the following means: /// /// /// /// Calling the GdiFlush function. /// /// /// Reaching or exceeding the batch limit set by the GdiSetBatchLimit function. /// /// /// Filling the batching buffers. /// /// /// Calling any GDI function that does not return a Boolean value. /// /// /// /// The return value for GdiFlush applies only to the functions in the batch at the time GdiFlush is called. Errors /// that occur when the batch is flushed by any other means are never reported. /// /// The GdiGetBatchLimit function returns the batch limit. /// /// Note The batch limit is maintained for each thread separately. In order to completely disable batching, call /// GdiSetBatchLimit (1) during the initialization of each thread. /// /// /// An application should call GdiFlush before a thread goes away if there is a possibility that there are pending function /// calls in the graphics batch queue. The system does not execute such batched functions when a thread goes away. /// /// /// A multithreaded application that serializes access to GDI objects with a mutex must ensure flushing the GDI batch queue by /// calling GdiFlush as each thread releases ownership of the GDI object. This prevents collisions of the GDI objects (device /// contexts, metafiles, and so on). /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdiflush BOOL GdiFlush( ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "6d2f398d-7a30-4b14-81de-23ab10e1749c")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GdiFlush(); /// /// The GdiGetBatchLimit function returns the maximum number of function calls that can be accumulated in the calling thread's /// current batch. The system flushes the current batch whenever this limit is exceeded. /// /// /// If the function succeeds, the return value is the batch limit. /// If the function fails, the return value is zero. /// /// /// The batch limit is set by using the GdiSetBatchLimit function. Setting the limit to 1 effectively disables batching. /// /// Only GDI drawing functions that return Boolean values can be batched; calls to any other GDI functions immediately flush the /// current batch. Exceeding the batch limit or calling the GdiFlush function also flushes the current batch. /// /// /// When the system batches a function call, the function returns TRUE. The actual return value for the function is reported /// only if GdiFlush is used to flush the batch. /// /// /// Note The batch limit is maintained for each thread separately. In order to completely disable batching, call /// GdiSetBatchLimit (1) during the initialization of each thread. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdigetbatchlimit DWORD GdiGetBatchLimit( ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "aafe7635-1a71-42a9-90b7-11179e245af4")] public static extern uint GdiGetBatchLimit(); /// The GdiGradientFill function fills rectangle and triangle structures. /// A handle to the destination device context. /// A pointer to an array of TRIVERTEX structures that each define a triangle vertex. /// The number of vertices in pVertex. /// /// An array of GRADIENT_TRIANGLE structures in triangle mode, or an array of GRADIENT_RECT structures in rectangle mode. /// /// The number of elements (triangles or rectangles) in pMesh. /// /// The gradient fill mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// GRADIENT_FILL_RECT_H /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the left and right edges. GDI interpolates the color from the left to right edge and fills the interior. /// /// /// /// GRADIENT_FILL_RECT_V /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the top and bottom edges. GDI interpolates the color from the top to bottom edge and fills the interior. /// /// /// /// GRADIENT_FILL_TRIANGLE /// /// In this mode, an array of TRIVERTEX structures is passed to GDI along with a list of array indexes that describe separate /// triangles. GDI performs linear interpolation between triangle vertices and fills the interior. Drawing is done directly in 24- /// and 32-bpp modes. Dithering is performed in 16-, 8-, 4-, and 1-bpp mode. /// /// /// /// /// /// If the function succeeds, the return value is TRUE. /// If the function fails, the return value is FALSE. /// /// /// Note This function is the same as GradientFill. /// /// To add smooth shading to a triangle, call the GdiGradientFill function with the three triangle endpoints. GDI will /// linearly interpolate and fill the triangle. Here is the drawing output of a shaded triangle. /// /// /// To add smooth shading to a rectangle, call GdiGradientFill with the upper-left and lower-right coordinates of the /// rectangle. There are two shading modes used when drawing a rectangle. In horizontal mode, the rectangle is shaded from /// left-to-right. In vertical mode, the rectangle is shaded from top-to-bottom. Here is the drawing output of two shaded rectangles /// - one in horizontal mode, the other in vertical mode. /// /// /// The GdiGradientFill function uses a mesh method to specify the endpoints of the object to draw. All vertices are passed /// to GdiGradientFill in the pVertex array. The pMesh parameter specifies how these vertices are connected to form an /// object. When filling a rectangle, pMesh points to an array of GRADIENT_RECT structures. Each GRADIENT_RECT structure /// specifies the index of two vertices in the pVertex array. These two vertices form the upper-left and lower-right boundary of one rectangle. /// /// /// In the case of filling a triangle, pMesh points to an array of GRADIENT_TRIANGLE structures. Each GRADIENT_TRIANGLE /// structure specifies the index of three vertices in the pVertex array. These three vertices form one triangle. /// /// To simplify hardware acceleration, this routine is not required to be pixel-perfect in the triangle interior. /// /// Note that GdiGradientFill does not use the Alpha member of the TRIVERTEX structure. To use GdiGradientFill with /// transparency, call GdiGradientFill and then call GdiAlphaBlend with the desired values for the alpha channel of each vertex. /// /// For more information, see Smooth Shading, Drawing a Shaded Triangle, and Drawing a Shaded Rectangle. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdigradientfill // BOOL GdiGradientFill( HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nCount, ULONG ulMode ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "c88c1137-5690-4139-9d10-90d036e8f31c")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GdiGradientFill(HDC hdc, in TRIVERTEX pVertex, uint nVertex, IntPtr pMesh, uint nCount, GradientFillMode ulMode); /// The GdiGradientFill function fills rectangle and triangle structures. /// A handle to the destination device context. /// A pointer to an array of TRIVERTEX structures that each define a triangle vertex. /// The number of vertices in pVertex. /// /// An array of GRADIENT_TRIANGLE structures in triangle mode, or an array of GRADIENT_RECT structures in rectangle mode. /// /// The number of elements (triangles or rectangles) in pMesh. /// /// The gradient fill mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// GRADIENT_FILL_RECT_H /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the left and right edges. GDI interpolates the color from the left to right edge and fills the interior. /// /// /// /// GRADIENT_FILL_RECT_V /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the top and bottom edges. GDI interpolates the color from the top to bottom edge and fills the interior. /// /// /// /// GRADIENT_FILL_TRIANGLE /// /// In this mode, an array of TRIVERTEX structures is passed to GDI along with a list of array indexes that describe separate /// triangles. GDI performs linear interpolation between triangle vertices and fills the interior. Drawing is done directly in 24- /// and 32-bpp modes. Dithering is performed in 16-, 8-, 4-, and 1-bpp mode. /// /// /// /// /// /// If the function succeeds, the return value is TRUE. /// If the function fails, the return value is FALSE. /// /// /// Note This function is the same as GradientFill. /// /// To add smooth shading to a triangle, call the GdiGradientFill function with the three triangle endpoints. GDI will /// linearly interpolate and fill the triangle. Here is the drawing output of a shaded triangle. /// /// /// To add smooth shading to a rectangle, call GdiGradientFill with the upper-left and lower-right coordinates of the /// rectangle. There are two shading modes used when drawing a rectangle. In horizontal mode, the rectangle is shaded from /// left-to-right. In vertical mode, the rectangle is shaded from top-to-bottom. Here is the drawing output of two shaded rectangles /// - one in horizontal mode, the other in vertical mode. /// /// /// The GdiGradientFill function uses a mesh method to specify the endpoints of the object to draw. All vertices are passed /// to GdiGradientFill in the pVertex array. The pMesh parameter specifies how these vertices are connected to form an /// object. When filling a rectangle, pMesh points to an array of GRADIENT_RECT structures. Each GRADIENT_RECT structure /// specifies the index of two vertices in the pVertex array. These two vertices form the upper-left and lower-right boundary of one rectangle. /// /// /// In the case of filling a triangle, pMesh points to an array of GRADIENT_TRIANGLE structures. Each GRADIENT_TRIANGLE /// structure specifies the index of three vertices in the pVertex array. These three vertices form one triangle. /// /// To simplify hardware acceleration, this routine is not required to be pixel-perfect in the triangle interior. /// /// Note that GdiGradientFill does not use the Alpha member of the TRIVERTEX structure. To use GdiGradientFill with /// transparency, call GdiGradientFill and then call GdiAlphaBlend with the desired values for the alpha channel of each vertex. /// /// For more information, see Smooth Shading, Drawing a Shaded Triangle, and Drawing a Shaded Rectangle. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdigradientfill // BOOL GdiGradientFill( HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nCount, ULONG ulMode ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "c88c1137-5690-4139-9d10-90d036e8f31c")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GdiGradientFill(HDC hdc, in TRIVERTEX pVertex, uint nVertex, [In, MarshalAs(UnmanagedType.LPArray)] GRADIENT_TRIANGLE[] pMesh, uint nCount, GradientFillMode ulMode); /// The GdiGradientFill function fills rectangle and triangle structures. /// A handle to the destination device context. /// A pointer to an array of TRIVERTEX structures that each define a triangle vertex. /// The number of vertices in pVertex. /// /// An array of GRADIENT_TRIANGLE structures in triangle mode, or an array of GRADIENT_RECT structures in rectangle mode. /// /// The number of elements (triangles or rectangles) in pMesh. /// /// The gradient fill mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// GRADIENT_FILL_RECT_H /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the left and right edges. GDI interpolates the color from the left to right edge and fills the interior. /// /// /// /// GRADIENT_FILL_RECT_V /// /// In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX /// structure) for the top and bottom edges. GDI interpolates the color from the top to bottom edge and fills the interior. /// /// /// /// GRADIENT_FILL_TRIANGLE /// /// In this mode, an array of TRIVERTEX structures is passed to GDI along with a list of array indexes that describe separate /// triangles. GDI performs linear interpolation between triangle vertices and fills the interior. Drawing is done directly in 24- /// and 32-bpp modes. Dithering is performed in 16-, 8-, 4-, and 1-bpp mode. /// /// /// /// /// /// If the function succeeds, the return value is TRUE. /// If the function fails, the return value is FALSE. /// /// /// Note This function is the same as GradientFill. /// /// To add smooth shading to a triangle, call the GdiGradientFill function with the three triangle endpoints. GDI will /// linearly interpolate and fill the triangle. Here is the drawing output of a shaded triangle. /// /// /// To add smooth shading to a rectangle, call GdiGradientFill with the upper-left and lower-right coordinates of the /// rectangle. There are two shading modes used when drawing a rectangle. In horizontal mode, the rectangle is shaded from /// left-to-right. In vertical mode, the rectangle is shaded from top-to-bottom. Here is the drawing output of two shaded rectangles /// - one in horizontal mode, the other in vertical mode. /// /// /// The GdiGradientFill function uses a mesh method to specify the endpoints of the object to draw. All vertices are passed /// to GdiGradientFill in the pVertex array. The pMesh parameter specifies how these vertices are connected to form an /// object. When filling a rectangle, pMesh points to an array of GRADIENT_RECT structures. Each GRADIENT_RECT structure /// specifies the index of two vertices in the pVertex array. These two vertices form the upper-left and lower-right boundary of one rectangle. /// /// /// In the case of filling a triangle, pMesh points to an array of GRADIENT_TRIANGLE structures. Each GRADIENT_TRIANGLE /// structure specifies the index of three vertices in the pVertex array. These three vertices form one triangle. /// /// To simplify hardware acceleration, this routine is not required to be pixel-perfect in the triangle interior. /// /// Note that GdiGradientFill does not use the Alpha member of the TRIVERTEX structure. To use GdiGradientFill with /// transparency, call GdiGradientFill and then call GdiAlphaBlend with the desired values for the alpha channel of each vertex. /// /// For more information, see Smooth Shading, Drawing a Shaded Triangle, and Drawing a Shaded Rectangle. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdigradientfill // BOOL GdiGradientFill( HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nCount, ULONG ulMode ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "c88c1137-5690-4139-9d10-90d036e8f31c")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GdiGradientFill(HDC hdc, in TRIVERTEX pVertex, uint nVertex, [In, MarshalAs(UnmanagedType.LPArray)] GRADIENT_RECT[] pMesh, uint nCount, GradientFillMode ulMode); /// /// The GdiSetBatchLimit function sets the maximum number of function calls that can be accumulated in the calling thread's /// current batch. The system flushes the current batch whenever this limit is exceeded. /// /// Specifies the batch limit to be set. A value of 0 sets the default limit. A value of 1 disables batching. /// /// If the function succeeds, the return value is the previous batch limit. /// If the function fails, the return value is zero. /// /// /// /// Only GDI drawing functions that return Boolean values can be accumulated in the current batch; calls to any other GDI functions /// immediately flush the current batch. Exceeding the batch limit or calling the GdiFlush function also flushes the current batch. /// /// /// When the system accumulates a function call, the function returns TRUE to indicate it is in the batch. When the system /// flushes the current batch and executes the function for the second time, the return value is either TRUE or FALSE, /// depending on whether the function succeeds. This second return value is reported only if GdiFlush is used to flush the batch. /// /// /// Note The batch limit is maintained for each thread separately. In order to completely disable batching, call /// GdiSetBatchLimit (1) during the initialization of each thread. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gdisetbatchlimit DWORD GdiSetBatchLimit( DWORD dw ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "53bf0dfe-e93c-401d-ac5d-6717bad2625e")] public static extern uint GdiSetBatchLimit(uint dw); /// The GetBkColor function returns the current background color for the specified device context. /// Handle to the device context whose background color is to be returned. /// /// If the function succeeds, the return value is a COLORREF value for the current background color. /// If the function fails, the return value is CLR_INVALID. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbkcolor COLORREF GetBkColor( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "1c6e8d05-4b8d-476d-852c-f06f316cb8b7")] public static extern COLORREF GetBkColor(HDC hdc); /// /// The GetBkMode function returns the current background mix mode for a specified device context. The background mix mode of /// a device context affects text, hatched brushes, and pen styles that are not solid lines. /// /// Handle to the device context whose background mode is to be returned. /// /// If the function succeeds, the return value specifies the current background mix mode, either OPAQUE or TRANSPARENT. /// If the function fails, the return value is zero. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbkmode int GetBkMode( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "3faedb48-3163-48fd-b26e-712de9c4bfaf")] public static extern BackgroundMode GetBkMode(HDC hdc); /// /// The GetBoundsRect function obtains the current accumulated bounding rectangle for a specified device context. /// /// The system maintains an accumulated bounding rectangle for each application. An application can retrieve and set this rectangle. /// /// /// A handle to the device context whose bounding rectangle the function will return. /// /// A pointer to the RECT structure that will receive the current bounding rectangle. The application's rectangle is returned in /// logical coordinates, and the bounding rectangle is returned in screen coordinates. /// /// /// Specifies how the GetBoundsRect function will behave. This parameter can be the following value. /// /// /// Value /// Meaning /// /// /// DCB_RESET /// Clears the bounding rectangle after returning it. If this flag is not set, the bounding rectangle will not be cleared. /// /// /// /// /// The return value specifies the state of the accumulated bounding rectangle; it can be one of the following values. /// /// /// Value /// Meaning /// /// /// 0 /// An error occurred. The specified device context handle is invalid. /// /// /// DCB_DISABLE /// Boundary accumulation is off. /// /// /// DCB_ENABLE /// Boundary accumulation is on. /// /// /// DCB_RESET /// The bounding rectangle is empty. /// /// /// DCB_SET /// The bounding rectangle is not empty. /// /// /// /// /// The DCB_SET value is a combination of the bit values DCB_ACCUMULATE and DCB_RESET. Applications that check the DCB_RESET bit to /// determine whether the bounding rectangle is empty must also check the DCB_ACCUMULATE bit. The bounding rectangle is empty only if /// the DCB_RESET bit is 1 and the DCB_ACCUMULATE bit is 0. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getboundsrect UINT GetBoundsRect( HDC hdc, LPRECT lprect, UINT // flags ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "139d4550-9adc-48b3-a15c-03ae1f1ef1ab")] public static extern DCB GetBoundsRect(HDC hdc, out RECT lprect, DCB flags); /// /// The GetROP2 function retrieves the foreground mix mode of the specified device context. The mix mode specifies how the pen /// or interior color and the color already on the screen are combined to yield a new color. /// /// Handle to the device context. /// /// If the function succeeds, the return value specifies the foreground mix mode. /// If the function fails, the return value is zero. /// /// /// Following are the foreground mix modes. /// /// /// Mix mode /// Description /// /// /// R2_BLACK /// Pixel is always 0. /// /// /// R2_COPYPEN /// Pixel is the pen color. /// /// /// R2_MASKNOTPEN /// Pixel is a combination of the colors common to both the screen and the inverse of the pen. /// /// /// R2_MASKPEN /// Pixel is a combination of the colors common to both the pen and the screen. /// /// /// R2_MASKPENNOT /// Pixel is a combination of the colors common to both the pen and the inverse of the screen. /// /// /// R2_MERGENOTPEN /// Pixel is a combination of the screen color and the inverse of the pen color. /// /// /// R2_MERGEPEN /// Pixel is a combination of the pen color and the screen color. /// /// /// R2_MERGEPENNOT /// Pixel is a combination of the pen color and the inverse of the screen color. /// /// /// R2_NOP /// Pixel remains unchanged. /// /// /// R2_NOT /// Pixel is the inverse of the screen color. /// /// /// R2_NOTCOPYPEN /// Pixel is the inverse of the pen color. /// /// /// R2_NOTMASKPEN /// Pixel is the inverse of the R2_MASKPEN color. /// /// /// R2_NOTMERGEPEN /// Pixel is the inverse of the R2_MERGEPEN color. /// /// /// R2_NOTXORPEN /// Pixel is the inverse of the R2_XORPEN color. /// /// /// R2_WHITE /// Pixel is always 1. /// /// /// R2_XORPEN /// Pixel is a combination of the colors in the pen and in the screen, but not in both. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getrop2 int GetROP2( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "ca1930e0-f6f4-44c8-979c-f50881f3c225")] public static extern R2 GetROP2(HDC hdc); /// /// The SetBkColor function sets the current background color to the specified color value, or to the nearest physical color /// if the device cannot represent the specified color value. /// /// A handle to the device context. /// The new background color. To make a COLORREF value, use the RGB macro. /// /// If the function succeeds, the return value specifies the previous background color as a COLORREF value. /// If the function fails, the return value is CLR_INVALID. /// /// /// /// This function fills the gaps between styled lines drawn using a pen created by the CreatePen function; it does not fill the gaps /// between styled lines drawn using a pen created by the ExtCreatePen function. The SetBkColor function also sets the /// background colors for TextOut and ExtTextOut. /// /// /// If the background mode is OPAQUE, the background color is used to fill gaps between styled lines, gaps between hatched lines in /// brushes, and character cells. The background color is also used when converting bitmaps from color to monochrome and vice versa. /// /// Examples /// For an example, see "Example of Owner-Drawn Menu Items" in Using Menus. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setbkcolor COLORREF SetBkColor( HDC hdc, COLORREF color ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "9163370b-19c5-4c23-9197-793e4b8d50c4")] public static extern COLORREF SetBkColor(HDC hdc, COLORREF color); /// /// The SetBkMode function sets the background mix mode of the specified device context. The background mix mode is used with /// text, hatched brushes, and pen styles that are not solid lines. /// /// A handle to the device context. /// /// The background mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// OPAQUE /// Background is filled with the current background color before the text, hatched brush, or pen is drawn. /// /// /// TRANSPARENT /// Background remains untouched. /// /// /// /// /// If the function succeeds, the return value specifies the previous background mode. /// If the function fails, the return value is zero. /// /// /// /// The SetBkMode function affects the line styles for lines drawn using a pen created by the CreatePen function. /// SetBkMode does not affect lines drawn using a pen created by the ExtCreatePen function. /// /// Examples /// /// To see how to make the background of a hatch brush transparent or opaque, refer to the example shown in the CreateHatchBrush topic. /// /// /// The next example draws a string 36 times, rotating it 10 degrees counterclockwise each time. It also sets the background mode to /// transparent to make the text visible. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setbkmode int SetBkMode( HDC hdc, int mode ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "60e4467a-14ab-421e-b174-4b9c0134ce72")] public static extern BackgroundMode SetBkMode(HDC hdc, BackgroundMode mode); /// /// The SetBoundsRect function controls the accumulation of bounding rectangle information for the specified device context. /// The system can maintain a bounding rectangle for all drawing operations. An application can examine and set this rectangle. The /// drawing boundaries are useful for invalidating bitmap caches. /// /// A handle to the device context for which to accumulate bounding rectangles. /// /// A pointer to a RECT structure used to set the bounding rectangle. Rectangle dimensions are in logical coordinates. This parameter /// can be NULL. /// /// /// /// Specifies how the new rectangle will be combined with the accumulated rectangle. This parameter can be one of more of the /// following values. /// /// /// /// Value /// Meaning /// /// /// DCB_ACCUMULATE /// /// Adds the rectangle specified by the lprcBounds parameter to the bounding rectangle (using a rectangle union operation). Using /// both DCB_RESET and DCB_ACCUMULATE sets the bounding rectangle to the rectangle specified by the lprcBounds parameter. /// /// /// /// DCB_DISABLE /// Turns off boundary accumulation. /// /// /// DCB_ENABLE /// Turns on boundary accumulation, which is disabled by default. /// /// /// DCB_RESET /// Clears the bounding rectangle. /// /// /// /// /// /// If the function succeeds, the return value specifies the previous state of the bounding rectangle. This state can be a /// combination of the following values. /// /// /// /// Value /// Meaning /// /// /// DCB_DISABLE /// Boundary accumulation is off. /// /// /// DCB_ENABLE /// Boundary accumulation is on. DCB_ENABLE and DCB_DISABLE are mutually exclusive. /// /// /// DCB_RESET /// Bounding rectangle is empty. /// /// /// DCB_SET /// Bounding rectangle is not empty. DCB_SET and DCB_RESET are mutually exclusive. /// /// /// If the function fails, the return value is zero. /// /// /// The DCB_SET value is a combination of the bit values DCB_ACCUMULATE and DCB_RESET. Applications that check the DCB_RESET bit to /// determine whether the bounding rectangle is empty must also check the DCB_ACCUMULATE bit. The bounding rectangle is empty only if /// the DCB_RESET bit is 1 and the DCB_ACCUMULATE bit is 0. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setboundsrect UINT SetBoundsRect( HDC hdc, const RECT *lprect, // UINT flags ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "ad361e78-42e8-4945-9395-fab983e396df")] public static extern DCB SetBoundsRect(HDC hdc, in RECT lprect, DCB flags); /// /// The SetBoundsRect function controls the accumulation of bounding rectangle information for the specified device context. /// The system can maintain a bounding rectangle for all drawing operations. An application can examine and set this rectangle. The /// drawing boundaries are useful for invalidating bitmap caches. /// /// A handle to the device context for which to accumulate bounding rectangles. /// /// A pointer to a RECT structure used to set the bounding rectangle. Rectangle dimensions are in logical coordinates. This parameter /// can be NULL. /// /// /// /// Specifies how the new rectangle will be combined with the accumulated rectangle. This parameter can be one of more of the /// following values. /// /// /// /// Value /// Meaning /// /// /// DCB_ACCUMULATE /// /// Adds the rectangle specified by the lprcBounds parameter to the bounding rectangle (using a rectangle union operation). Using /// both DCB_RESET and DCB_ACCUMULATE sets the bounding rectangle to the rectangle specified by the lprcBounds parameter. /// /// /// /// DCB_DISABLE /// Turns off boundary accumulation. /// /// /// DCB_ENABLE /// Turns on boundary accumulation, which is disabled by default. /// /// /// DCB_RESET /// Clears the bounding rectangle. /// /// /// /// /// /// If the function succeeds, the return value specifies the previous state of the bounding rectangle. This state can be a /// combination of the following values. /// /// /// /// Value /// Meaning /// /// /// DCB_DISABLE /// Boundary accumulation is off. /// /// /// DCB_ENABLE /// Boundary accumulation is on. DCB_ENABLE and DCB_DISABLE are mutually exclusive. /// /// /// DCB_RESET /// Bounding rectangle is empty. /// /// /// DCB_SET /// Bounding rectangle is not empty. DCB_SET and DCB_RESET are mutually exclusive. /// /// /// If the function fails, the return value is zero. /// /// /// The DCB_SET value is a combination of the bit values DCB_ACCUMULATE and DCB_RESET. Applications that check the DCB_RESET bit to /// determine whether the bounding rectangle is empty must also check the DCB_ACCUMULATE bit. The bounding rectangle is empty only if /// the DCB_RESET bit is 1 and the DCB_ACCUMULATE bit is 0. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setboundsrect UINT SetBoundsRect( HDC hdc, const RECT *lprect, // UINT flags ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "ad361e78-42e8-4945-9395-fab983e396df")] public static extern DCB SetBoundsRect(HDC hdc, [Optional] IntPtr lprect, DCB flags); /// /// The SetROP2 function sets the current foreground mix mode. GDI uses the foreground mix mode to combine pens and interiors /// of filled objects with the colors already on the screen. The foreground mix mode defines how colors from the brush or pen and the /// colors in the existing image are to be combined. /// /// A handle to the device context. /// /// The mix mode. This parameter can be one of the following values. /// /// /// Mix mode /// Meaning /// /// /// R2_BLACK /// Pixel is always 0. /// /// /// R2_COPYPEN /// Pixel is the pen color. /// /// /// R2_MASKNOTPEN /// Pixel is a combination of the colors common to both the screen and the inverse of the pen. /// /// /// R2_MASKPEN /// Pixel is a combination of the colors common to both the pen and the screen. /// /// /// R2_MASKPENNOT /// Pixel is a combination of the colors common to both the pen and the inverse of the screen. /// /// /// R2_MERGENOTPEN /// Pixel is a combination of the screen color and the inverse of the pen color. /// /// /// R2_MERGEPEN /// Pixel is a combination of the pen color and the screen color. /// /// /// R2_MERGEPENNOT /// Pixel is a combination of the pen color and the inverse of the screen color. /// /// /// R2_NOP /// Pixel remains unchanged. /// /// /// R2_NOT /// Pixel is the inverse of the screen color. /// /// /// R2_NOTCOPYPEN /// Pixel is the inverse of the pen color. /// /// /// R2_NOTMASKPEN /// Pixel is the inverse of the R2_MASKPEN color. /// /// /// R2_NOTMERGEPEN /// Pixel is the inverse of the R2_MERGEPEN color. /// /// /// R2_NOTXORPEN /// Pixel is the inverse of the R2_XORPEN color. /// /// /// R2_WHITE /// Pixel is always 1. /// /// /// R2_XORPEN /// Pixel is a combination of the colors in the pen and in the screen, but not in both. /// /// /// /// /// If the function succeeds, the return value specifies the previous mix mode. /// If the function fails, the return value is zero. /// /// /// /// Mix modes define how GDI combines source and destination colors when drawing with the current pen. The mix modes are binary /// raster operation codes, representing all possible Boolean functions of two variables, using the binary operations AND, OR, and /// XOR (exclusive OR), and the unary operation NOT. The mix mode is for raster devices only; it is not available for vector devices. /// /// Examples /// For an example, see Using Rectangles. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setrop2 int SetROP2( HDC hdc, int rop2 ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "a462a03d-e2c8-403e-aab4-ae03fb96f06f")] public static extern R2 SetROP2(HDC hdc, R2 rop2); } }