using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using static Vanara.PInvoke.Gdi32; using static Vanara.PInvoke.User32; namespace Vanara.PInvoke { public static partial class ComCtl32 { /// /// /// The set of bit flags that specifies the type of image list to create. This parameter can be a combination of the following /// values, but it can include only one of the ILC_COLOR values. Used by ImageList_Create and IImageList2::Initialize. /// /// /// /// /// Constant/value /// Description /// /// /// ILC_MASK0x00000001 /// /// Use a mask. The image list contains two bitmaps, one of which is a monochrome bitmap used as a mask. If this value is not /// included, the image list contains only one bitmap. /// /// /// /// ILC_COLOR0x00000000 /// /// Use the default behavior if none of the other ILC_COLORx flags is specified. Typically, the default is ILC_COLOR4, but for older /// display drivers, the default is ILC_COLORDDB. /// /// /// /// ILC_COLORDDB0x000000FE /// Use a device-dependent bitmap. /// /// /// ILC_COLOR40x00000004 /// Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list. /// /// /// ILC_COLOR80x00000008 /// Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette. /// /// /// ILC_COLOR160x00000010 /// Use a 16-bit (32/64k-color) DIB section. /// /// /// ILC_COLOR240x00000018 /// Use a 24-bit DIB section. /// /// /// ILC_COLOR320x00000020 /// Use a 32-bit DIB section. /// /// /// ILC_PALETTE0x00000800 /// Not implemented. /// /// /// ILC_MIRROR0x00002000 /// Mirror the icons contained, if the process is mirrored /// /// /// ILC_PERITEMMIRROR0x00008000 /// Causes the mirroring code to mirror each item when inserting a set of images, versus the whole strip. /// /// /// ILC_ORIGINALSIZE0x00010000 /// Windows Vista and later. Imagelist should accept smaller than set images and apply original size based on image added. /// /// /// ILC_HIGHQUALITYSCALE0x00020000 /// Windows Vista and later. Reserved. /// /// /// /// /// // https://msdn.microsoft.com/en-us/library/windows/desktop/bb775232(v=vs.85).aspx [PInvokeData("Shlobj.h", MSDNShortId = "bb775232")] [Flags] public enum ILC : uint { /// /// Use a mask. The image list contains two bitmaps, one of which is a monochrome bitmap used as a mask. If this value is not /// included, the image list contains only one bitmap. /// ILC_MASK = 0x00000001, /// /// Use the default behavior if none of the other ILC_COLORx flags is specified. Typically, the default is ILC_COLOR4, but for /// older display drivers, the default is ILC_COLORDDB. /// ILC_COLOR = 0x00000000, /// Use a device-dependent bitmap. ILC_COLORDDB = 0x000000FE, /// Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list. ILC_COLOR4 = 0x00000004, /// Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette. ILC_COLOR8 = 0x00000008, /// Use a 16-bit (32/64k-color) DIB section. ILC_COLOR16 = 0x00000010, /// Use a 24-bit DIB section. ILC_COLOR24 = 0x00000018, /// Use a 32-bit DIB section. ILC_COLOR32 = 0x00000020, /// Not implemented. ILC_PALETTE = 0x00000800, /// Mirror the icons contained, if the process is mirrored ILC_MIRROR = 0x00002000, /// Causes the mirroring code to mirror each item when inserting a set of images, versus the whole strip. ILC_PERITEMMIRROR = 0x00008000, /// /// Windows Vista and later. Imagelist should accept smaller than set images and apply original size based on image added. /// ILC_ORIGINALSIZE = 0x00010000, /// Windows Vista and later. Reserved. ILC_HIGHQUALITYSCALE = 0x00020000, } /// Discard images flags. [Flags] public enum ILDI : uint { /// Discard and purge. ILDI_PURGE = 0x00000001, /// Discard to standby list. ILDI_STANDBY = 0x00000002, /// Reset the "has been accessed" flag. ILDI_RESETACCESS = 0x00000004, /// Ask whether access flag is set (but do not reset). ILDI_QUERYACCESS = 0x00000008, } /// Force image flags. public enum ILFIP { /// Always get the image (can be slow). ILFIP_ALWAYS = 0x00000000, /// Only get if on standby. ILFIP_FROMSTANDBY = 0x00000001, } /// Flags for getting original size. public enum ILGOS { /// Always get the original size (can be slow). ILGOS_ALWAYS = 0x00000000, /// Only get if present or on standby. ILGOS_FROMSTANDBY = 0x00000001, } /// A flag that specifies how the stream is read. public enum ILP { /// Expects an image list that was written with the ILP_NORMAL flag specified. ILP_NORMAL, /// Expects an image list that was written with the ILP_DOWNLEVEL flag specified. ILP_DOWNLEVEL } /// Specifies how the mask is applied to the image as one or a bitwise combination of the following decoration flags. [Flags] public enum ILR { /// Not used. ILR_DEFAULT = 0x0000, /// Horizontally align to left. ILR_HORIZONTAL_LEFT = 0x0000, /// Horizontally center. ILR_HORIZONTAL_CENTER = 0x0001, /// Horizontally align to right. ILR_HORIZONTAL_RIGHT = 0x0002, /// Vertically align to top. ILR_VERTICAL_TOP = 0x0000, /// Vertically align to center. ILR_VERTICAL_CENTER = 0x0010, /// Vertically align to bottom. ILR_VERTICAL_BOTTOM = 0x0020, /// Do nothing. ILR_SCALE_CLIP = 0x0000, /// Scale. ILR_SCALE_ASPECTRATIO = 0x0100, } /// Flags used when copying image lists. [PInvokeData("Commctrl.h", MSDNShortId = "bb775230")] public enum IMAGELISTCOPYFLAG { /// /// The source image is copied to the destination image's index. This operation results in multiple instances of a given image. /// ILCF_MOVE = 0, /// The source and destination images exchange positions within the image list. ILCF_SWAP = 1 } /// Passed to the IImageList::Draw method in the fStyle member of IMAGELISTDRAWPARAMS. [PInvokeData("Commctrl.h", MSDNShortId = "bb775230")] [Flags] public enum IMAGELISTDRAWFLAGS : uint { /// /// Draws the image using the background color for the image list. If the background color is the CLR_NONE value, the image is /// drawn transparently using the mask. /// ILD_NORMAL = 0X00000000, /// /// Draws the image transparently using the mask, regardless of the background color. This value has no effect if the image list /// does not contain a mask. /// ILD_TRANSPARENT = 0x00000001, /// /// Draws the image, blending 25 percent with the blend color specified by rgbFg. This value has no effect if the image list does /// not contain a mask. /// ILD_BLEND25 = 0X00000002, /// Same as ILD_BLEND25 ILD_FOCUS = ILD_BLEND25, /// /// Draws the image, blending 50 percent with the blend color specified by rgbFg. This value has no effect if the image list does /// not contain a mask. /// ILD_BLEND50 = 0X00000004, /// Same as ILD_BLEND50 ILD_SELECTED = ILD_BLEND50, /// Same as ILD_BLEND50 ILD_BLEND = ILD_BLEND50, /// Draws the mask. ILD_MASK = 0X00000010, /// If the overlay does not require a mask to be drawn, set this flag. ILD_IMAGE = 0X00000020, /// Draws the image using the raster operation code specified by the dwRop member. ILD_ROP = 0X00000040, /// /// To extract the overlay image from the fStyle member, use the logical AND to combine fStyle with the ILD_OVERLAYMASK value. /// ILD_OVERLAYMASK = 0x00000F00, /// Preserves the alpha channel in the destination. ILD_PRESERVEALPHA = 0x00001000, /// Causes the image to be scaled to cx, cy instead of being clipped. ILD_SCALE = 0X00002000, /// Scales the image to the current dpi of the display. ILD_DPISCALE = 0X00004000, /// /// Windows Vista and later. Draw the image if it is available in the cache. Do not extract it automatically. The called /// draw method returns E_PENDING to the calling component, which should then take an alternative action, such as, provide /// another image and queue a background task to force the image to be loaded via ForceImagePresent using the ILFIP_ALWAYS flag. /// The ILD_ASYNC flag then prevents the extraction operation from blocking the current thread and is especially important if a /// draw method is called from the user interface (UI) thread. /// ILD_ASYNC = 0X00008000 } /// Item flags. [PInvokeData("Commctrl.h", MSDNShortId = "bb761486")] public enum IMAGELISTITEMFLAG { /// Indicates that the item in the imagelist has an alpha channel. ILIF_ALPHA = 1, /// /// Windows Vista and later. Indicates that the item in the imagelist was generated via a StretchBlt function, consequently image /// quality may have degraded. /// ILIF_LOWQUALITY = 2 } /// The following flags are passed to the IImageList::Draw method in the fState member of IMAGELISTDRAWPARAMS. [PInvokeData("Commctrl.h", MSDNShortId = "bb775231")] [Flags] public enum IMAGELISTSTATEFLAGS { /// The image state is not modified. ILS_NORMAL = 0x00000000, /// Not supported. ILS_GLOW = 0x00000001, /// Not supported. ILS_SHADOW = 0x00000002, /// Reduces the color saturation of the icon to grayscale. This only affects 32bpp images. ILS_SATURATE = 0x00000004, /// /// Alpha blends the icon. Alpha blending controls the transparency level of an icon, according to the value of its alpha /// channel. The value of the alpha channel is indicated by the frame member in the IMAGELISTDRAWPARAMS method. The alpha channel /// can be from 0 to 255, with 0 being completely transparent, and 255 being completely opaque. /// ILS_ALPHA = 0x00000008, } /// Exposes methods that manipulate and interact with image lists. [PInvokeData("Commctrl.h", MSDNShortId = "bb761490")] [ComImport, Guid("46EB5926-582E-4017-9FDF-E8998DAA0950"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(CImageList))] public interface IImageList { /// Adds an image or images to an image list. /// /// A handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap. /// /// /// A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored. /// /// /// When this method returns, contains a pointer to the index of the first new image. If the method fails to successfully add the /// new image, this value is -1. /// int Add(HBITMAP hbmImage, [Optional] HBITMAP hbmMask); /// Replaces an image with an icon or cursor. /// /// A value of type int that contains the index of the image to replace. If i is -1, the function adds the image to the end of /// the list. /// /// A handle to the icon or cursor that contains the bitmap and mask for the new image. /// A pointer to an int that will contain the index of the image on return if successful, or -1 otherwise. int ReplaceIcon(int i, HICON hicon); /// /// Adds a specified image to the list of images used as overlay masks. An image list can have up to four overlay masks in Common /// Controls version 4.70 and earlier, and up to 15 in version 4.71 or later. The method assigns an overlay mask index to the /// specified image. /// /// /// A value of type int that contains the zero-based index of an image in the image list. This index identifies the image to use /// as an overlay mask. /// /// A value of type int that contains the one-based index of the overlay mask. void SetOverlayImage(int iImage, int iOverlay); /// Replaces an image in an image list with a new image. /// A value of type int that contains the index of the image to replace. /// A handle to the bitmap that contains the image. /// /// A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored. /// void Replace(int i, HBITMAP hbmImage, [Optional] HBITMAP hbmMask); /// Adds an image or images to an image list, generating a mask from the specified bitmap. /// /// A handle to the bitmap that contains one or more images. The number of images is inferred from the width of the bitmap. /// /// /// The color used to generate the mask. Each pixel of this color in the specified bitmap is changed to black, and the /// corresponding bit in the mask is set to 1. /// /// A pointer to an int that contains the index of the first new image when it returns, if successful, or -1 otherwise. int AddMasked(HBITMAP hbmImage, COLORREF crMask); /// Draws an image list item in the specified device context. /// A pointer to an IMAGELISTDRAWPARAMS structure that contains the drawing parameters. void Draw(IMAGELISTDRAWPARAMS pimldp); /// Removes an image from an image list. /// /// A value of type int that contains the index of the image to remove. If this parameter is -1, the method removes all images. /// void Remove(int i); /// Creates an icon from an image and a mask in an image list. /// A value of type int that contains the index of the image. /// A combination of flags that specify the drawing style. For a list of values, see IImageList::Draw. /// A pointer to an int that contains the handle to the icon if successful, or NULL if otherwise. SafeHICON GetIcon(int i, IMAGELISTDRAWFLAGS flags); /// Gets information about an image. /// A value of type int that contains the index of the image. /// /// A pointer to an IMAGEINFO structure that receives information about the image. The information in this structure can directly /// manipulate the bitmaps of the image. /// IMAGEINFO GetImageInfo(int i); /// Copies images from a given image list. /// A value of type int that contains the zero-based index of the destination image for the copy operation. /// A pointer to the IUnknown interface for the source image list. /// A value of type int that contains the zero-based index of the source image for the copy operation. /// A value that specifies the type of copy operation to be made. void Copy(int iDst, IImageList punkSrc, int iSrc, IMAGELISTCOPYFLAG uFlags); /// /// Creates a new image by combining two existing images. This method also creates a new image list in which to store the image. /// /// A value of type int that contains the index of the first existing image. /// A pointer to the IUnknown interface of the image list that contains the second image. /// A value of type int that contains the index of the second existing image. /// /// A value of type int that contains the x-component of the offset of the second image relative to the first image. /// /// /// A value of type int that contains the y-component of the offset of the second image relative to the first image. /// /// An IID of the interface for the new image list. /// A raw pointer to the interface for the new image list. IImageList Merge(int i1, IImageList punk2, int i2, int dx, int dy, in Guid riid); /// Clones an existing image list. /// An IID for the new image list. /// The address of a pointer to the interface for the new image list. IImageList Clone(in Guid riid); /// Gets an image's bounding rectangle. /// A value of type int that contains the index of the image. /// A pointer to a RECT that contains the bounding rectangle when the method returns. RECT GetImageRect(int i); /// Gets the dimensions of images in an image list. All images in an image list have the same dimensions. /// A pointer to an int that receives the width, in pixels, of each image. /// A pointer to an int that receives the height, in pixels, of each image. void GetIconSize(out int cx, out int cy); /// Sets the dimensions of images in an image list and removes all images from the list. /// /// A value of type int that contains the width, in pixels, of the images in the image list. All images in an image list have the /// same dimensions. /// /// /// A value of type int that contains the height, in pixels, of the images in the image list. All images in an image list have /// the same dimensions. /// void SetIconSize(int cx, int cy); /// Gets the number of images in an image list. /// A pointer to an int that contains the number of images when the method returns. int GetImageCount(); /// Resizes an existing image list. /// A value that specifies the new size of the image list. void SetImageCount(int uNewCount); /// /// Sets the background color for an image list. This method only functions if you add an icon to the image list or use the /// IImageList::AddMasked method to add a black and white bitmap. Without a mask, the entire image draws, and the background /// color is not visible. /// /// /// The background color to set. If this parameter is set to CLR_NONE, then images draw transparently using the mask. /// /// /// A pointer to a COLORREF that contains the previous background color on return if successful, or CLR_NONE otherwise. /// void SetBkColor(COLORREF clrBk, out COLORREF pclr); /// Gets the current background color for an image list. /// A pointer to a COLORREF that contains the background color when the method returns. COLORREF GetBkColor(); /// Begins dragging an image. /// A value of type int that contains the index of the image to drag. /// /// A value of type int that contains the x-component of the drag position relative to the upper-left corner of the image. /// /// /// A value of type int that contains the y-component of the drag position relative to the upper-left corner of the image. /// void BeginDrag(int iTrack, int dxHotspot, int dyHotspot); /// Ends a drag operation. void EndDrag(); /// /// Locks updates to the specified window during a drag operation and displays the drag image at the specified position within /// the window. /// /// A handle to the window that owns the drag image. /// /// The x-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not /// the client area. /// /// /// The y-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not /// the client area. /// void DragEnter(HWND hwndLock, int x, int y); /// Unlocks the specified window and hides the drag image, which enables the window to update. /// A handle to the window that contains the drag image. void DragLeave(HWND hwndLock); /// /// Moves the image that is being dragged during a drag-and-drop operation. This function is typically called in response to a /// WM_MOUSEMOVE message. /// /// /// A value of type int that contains the x-coordinate where the drag image appears. The coordinate is relative to the upper-left /// corner of the window, not the client area. /// /// /// A value of type int that contains the y-coordinate where the drag image appears. The coordinate is relative to the upper-left /// corner of the window, not the client area. /// void DragMove(int x, int y); /// /// Creates a new drag image by combining the specified image, which is typically a mouse cursor image, with the current drag image. /// /// /// A pointer to the IUnknown interface that accesses the image list interface, which contains the new image to combine with the /// drag image. /// /// A value of type int that contains the index of the new image to combine with the drag image. /// A value of type int that contains the x-component of the hot spot within the new image. /// A value of type int that contains the x-component of the hot spot within the new image. void SetDragCursorImage(IImageList punk, int iDrag, int dxHotspot, int dyHotspot); /// Shows or hides the image being dragged. /// /// A value that specifies whether to show or hide the image being dragged. Specify TRUE to show the image or FALSE to hide the image. /// void DragShowNolock([MarshalAs(UnmanagedType.Bool)] bool fShow); /// /// Gets the temporary image list that is used for the drag image. The function also retrieves the current drag position and the /// offset of the drag image relative to the drag position. /// /// A pointer to a POINT structure that receives the current drag position. Can be NULL. /// /// A pointer to a POINT structure that receives the offset of the drag image relative to the drag position. Can be NULL. /// /// An IID for the image list. /// The address of a pointer to the interface for the image list if successful, NULL otherwise. IImageList GetDragImage(out POINT ppt, out POINT pptHotspot, in Guid riid); /// Gets the flags of an image. /// A value of type int that contains the index of the images whose flags need to be retrieved. /// A pointer to a DWORD that contains the flags when the method returns. IMAGELISTITEMFLAG GetItemFlags(int i); /// Gets the overlay image. /// The i overlay. /// int GetOverlayImage(int iOverlay); } /// Extends IImageList by providing additional methods for manipulating and interacting with image lists. [PInvokeData("Commctrl.h", MSDNShortId = "bb761419")] [ComImport, Guid("192b9d83-50fc-457b-90a0-2b82a8b5dae1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(CImageList))] public interface IImageList2 : IImageList { /// Adds an image or images to an image list. /// /// A handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap. /// /// /// A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored. /// /// /// When this method returns, contains a pointer to the index of the first new image. If the method fails to successfully add the /// new image, this value is -1. /// new int Add(HBITMAP hbmImage, [Optional] HBITMAP hbmMask); /// Replaces an image with an icon or cursor. /// /// A value of type int that contains the index of the image to replace. If i is -1, the function adds the image to the end of /// the list. /// /// A handle to the icon or cursor that contains the bitmap and mask for the new image. /// A pointer to an int that will contain the index of the image on return if successful, or -1 otherwise. new int ReplaceIcon(int i, HICON hicon); /// /// Adds a specified image to the list of images used as overlay masks. An image list can have up to four overlay masks in Common /// Controls version 4.70 and earlier, and up to 15 in version 4.71 or later. The method assigns an overlay mask index to the /// specified image. /// /// /// A value of type int that contains the zero-based index of an image in the image list. This index identifies the image to use /// as an overlay mask. /// /// A value of type int that contains the one-based index of the overlay mask. new void SetOverlayImage(int iImage, int iOverlay); /// Replaces an image in an image list with a new image. /// A value of type int that contains the index of the image to replace. /// A handle to the bitmap that contains the image. /// /// A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored. /// new void Replace(int i, HBITMAP hbmImage, [Optional] HBITMAP hbmMask); /// Adds an image or images to an image list, generating a mask from the specified bitmap. /// /// A handle to the bitmap that contains one or more images. The number of images is inferred from the width of the bitmap. /// /// /// The color used to generate the mask. Each pixel of this color in the specified bitmap is changed to black, and the /// corresponding bit in the mask is set to 1. /// /// A pointer to an int that contains the index of the first new image when it returns, if successful, or -1 otherwise. new int AddMasked(HBITMAP hbmImage, COLORREF crMask); /// Draws an image list item in the specified device context. /// A pointer to an IMAGELISTDRAWPARAMS structure that contains the drawing parameters. new void Draw(IMAGELISTDRAWPARAMS pimldp); /// Removes an image from an image list. /// /// A value of type int that contains the index of the image to remove. If this parameter is -1, the method removes all images. /// new void Remove(int i); /// Creates an icon from an image and a mask in an image list. /// A value of type int that contains the index of the image. /// A combination of flags that specify the drawing style. For a list of values, see IImageList::Draw. /// A pointer to an int that contains the handle to the icon if successful, or NULL if otherwise. new IntPtr GetIcon(int i, IMAGELISTDRAWFLAGS flags); /// Gets information about an image. /// A value of type int that contains the index of the image. /// /// A pointer to an IMAGEINFO structure that receives information about the image. The information in this structure can directly /// manipulate the bitmaps of the image. /// new IMAGEINFO GetImageInfo(int i); /// Copies images from a given image list. /// A value of type int that contains the zero-based index of the destination image for the copy operation. /// A pointer to the IUnknown interface for the source image list. /// A value of type int that contains the zero-based index of the source image for the copy operation. /// A value that specifies the type of copy operation to be made. new void Copy(int iDst, IImageList punkSrc, int iSrc, IMAGELISTCOPYFLAG uFlags); /// /// Creates a new image by combining two existing images. This method also creates a new image list in which to store the image. /// /// A value of type int that contains the index of the first existing image. /// A pointer to the IUnknown interface of the image list that contains the second image. /// A value of type int that contains the index of the second existing image. /// /// A value of type int that contains the x-component of the offset of the second image relative to the first image. /// /// /// A value of type int that contains the y-component of the offset of the second image relative to the first image. /// /// An IID of the interface for the new image list. /// A raw pointer to the interface for the new image list. new IImageList Merge(int i1, IImageList punk2, int i2, int dx, int dy, in Guid riid); /// Clones an existing image list. /// An IID for the new image list. /// The address of a pointer to the interface for the new image list. new IImageList Clone(in Guid riid); /// Gets an image's bounding rectangle. /// A value of type int that contains the index of the image. /// A pointer to a RECT that contains the bounding rectangle when the method returns. new RECT GetImageRect(int i); /// Gets the dimensions of images in an image list. All images in an image list have the same dimensions. /// A pointer to an int that receives the width, in pixels, of each image. /// A pointer to an int that receives the height, in pixels, of each image. new void GetIconSize(out int cx, out int cy); /// Sets the dimensions of images in an image list and removes all images from the list. /// /// A value of type int that contains the width, in pixels, of the images in the image list. All images in an image list have the /// same dimensions. /// /// /// A value of type int that contains the height, in pixels, of the images in the image list. All images in an image list have /// the same dimensions. /// new void SetIconSize(int cx, int cy); /// Gets the number of images in an image list. /// A pointer to an int that contains the number of images when the method returns. new int GetImageCount(); /// Resizes an existing image list. /// A value that specifies the new size of the image list. new void SetImageCount(int uNewCount); /// /// Sets the background color for an image list. This method only functions if you add an icon to the image list or use the /// IImageList::AddMasked method to add a black and white bitmap. Without a mask, the entire image draws, and the background /// color is not visible. /// /// /// The background color to set. If this parameter is set to CLR_NONE, then images draw transparently using the mask. /// /// /// A pointer to a COLORREF that contains the previous background color on return if successful, or CLR_NONE otherwise. /// new void SetBkColor(COLORREF clrBk, out COLORREF pclr); /// Gets the current background color for an image list. /// A pointer to a COLORREF that contains the background color when the method returns. new COLORREF GetBkColor(); /// Begins dragging an image. /// A value of type int that contains the index of the image to drag. /// /// A value of type int that contains the x-component of the drag position relative to the upper-left corner of the image. /// /// /// A value of type int that contains the y-component of the drag position relative to the upper-left corner of the image. /// new void BeginDrag(int iTrack, int dxHotspot, int dyHotspot); /// Ends a drag operation. new void EndDrag(); /// /// Locks updates to the specified window during a drag operation and displays the drag image at the specified position within /// the window. /// /// A handle to the window that owns the drag image. /// /// The x-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not /// the client area. /// /// /// The y-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not /// the client area. /// new void DragEnter(HWND hwndLock, int x, int y); /// Unlocks the specified window and hides the drag image, which enables the window to update. /// A handle to the window that contains the drag image. new void DragLeave(HWND hwndLock); /// /// Moves the image that is being dragged during a drag-and-drop operation. This function is typically called in response to a /// WM_MOUSEMOVE message. /// /// /// A value of type int that contains the x-coordinate where the drag image appears. The coordinate is relative to the upper-left /// corner of the window, not the client area. /// /// /// A value of type int that contains the y-coordinate where the drag image appears. The coordinate is relative to the upper-left /// corner of the window, not the client area. /// new void DragMove(int x, int y); /// /// Creates a new drag image by combining the specified image, which is typically a mouse cursor image, with the current drag image. /// /// /// A pointer to the IUnknown interface that accesses the image list interface, which contains the new image to combine with the /// drag image. /// /// A value of type int that contains the index of the new image to combine with the drag image. /// A value of type int that contains the x-component of the hot spot within the new image. /// A value of type int that contains the x-component of the hot spot within the new image. new void SetDragCursorImage(IImageList punk, int iDrag, int dxHotspot, int dyHotspot); /// Shows or hides the image being dragged. /// /// A value that specifies whether to show or hide the image being dragged. Specify TRUE to show the image or FALSE to hide the image. /// new void DragShowNolock([MarshalAs(UnmanagedType.Bool)] bool fShow); /// /// Gets the temporary image list that is used for the drag image. The function also retrieves the current drag position and the /// offset of the drag image relative to the drag position. /// /// A pointer to a POINT structure that receives the current drag position. Can be NULL. /// /// A pointer to a POINT structure that receives the offset of the drag image relative to the drag position. Can be NULL. /// /// An IID for the image list. /// The address of a pointer to the interface for the image list if successful, NULL otherwise. new IImageList GetDragImage(out POINT ppt, out POINT pptHotspot, in Guid riid); /// Gets the flags of an image. /// A value of type int that contains the index of the images whose flags need to be retrieved. /// A pointer to a DWORD that contains the flags when the method returns. new IMAGELISTITEMFLAG GetItemFlags(int i); /// Retrieves a specified image from the list of images used as overlay masks. /// A value of type int that contains the one-based index of the overlay mask. /// /// A pointer to an int that receives the zero-based index of an image in the image list. This index identifies the image that is /// used as an overlay mask. /// new int GetOverlayImage(int iOverlay); /// Resizes the current image. /// The x-axis count, in pixels, for the new size. /// The y-axis count, in pixels, for the new size. void Resize(int cxNewIconSize, int cyNewIconSize); /// Gets the original size of a specified image. /// The index of desired image. /// Flags for getting original size. /// A pointer to the x-axis count. /// A pointer to the y-axis count. void GetOriginalSize(int iImage, ILGOS dwFlags, out int pcx, out int pcy); /// Sets the original size of a specified image. /// An index of desired image. /// The x-axis count. /// The y-axis count. void SetOriginalSize(int iImage, int cx, int cy); /// Sets an image list callback. /// A pointer to the callback interface. void SetCallback([MarshalAs(UnmanagedType.IUnknown)] object punk); /// Gets an image list callback object. /// Reference to a desired IID. /// Contains the address of a pointer to a callback object. [return: MarshalAs(UnmanagedType.IUnknown)] object GetCallback(in Guid riid); /// Forces an image present, as specified. /// An index of image to force present. /// Force image flags. void ForceImagePresent(int iImage, uint dwFlags); /// Discards images from list, as specified. /// An index of first image to discard. /// An index of last image to discard. /// /// Discard images flags. ILDI_STANDBY and ILDI_PURGE are mutually exclusive. ILDI_RESETACCESS can be combined with either. /// void DiscardImages(int iFirstImage, int iLastImage, ILDI dwFlags); /// Preloads images, as specified. /// A pointer to an IMAGELISTDRAWPARAMS structure containing information about an image list draw operation. void PreloadImages(ref IMAGELISTDRAWPARAMS pimldp); /// Gets an image list statistics structure. /// A pointer to the IMAGELISTSTATS structure. IMAGELISTSTATS GetStatistics(); /// Initializes an image list. /// Width, in pixels, of each image. /// Height, in pixels, of each image. /// A combination of Image List Creation Flags. /// Number of images that the image list initially contains. /// Number of new images that the image list can contain. void Initialize(int cx, int cy, uint flags, int cInitial, int cGrow); /// Replaces an image in an image list. /// The index of the image to replace. /// A handle to the bitmap that contains the image. /// /// A handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored. /// /// A pointer to the IUnknown interface. /// /// Specifies how the mask is applied to the image as one or a bitwise combination of the following decoration flags. /// void Replace2(int i, HBITMAP hbmImage, HBITMAP hbmMask, [MarshalAs(UnmanagedType.IUnknown)] object punk, ILR dwFlags); /// Replaces an image in one image list with an image from another image list. /// /// The index of the destination image in the image list. This is the image that is overwritten by the new image. /// /// A pointer to the source image list. /// The index of the source image in the image list pointed to by pil. /// A pointer to the IUnknown interface. /// Not used; must be 0. void ReplaceFromImageList(int i, IImageList pil, int iSrc, [MarshalAs(UnmanagedType.IUnknown)] object punk, uint dwFlags = 0); } /// Gets the dimensions of images in an image list. All images in an image list have the same dimensions. /// The instance. /// The size of images. public static SIZE GetIconSize(this IImageList il) { il.GetIconSize(out var cx, out var cy); return new SIZE(cx, cy); } /// Get an image list interface from an image list handle. /// /// Type: HIMAGELIST /// A handle to the image list to query. /// /// /// Type: REFIID /// Reference to the desired interface ID. /// /// /// Type: void** /// /// When this method returns, contains the interface pointer requested in riid. This is normally IImageList2, which provides /// the Initialize method. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h")] public static extern HRESULT HIMAGELIST_QueryInterface(HIMAGELIST himl, in Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Get an image list interface from an image list handle. /// /// Type: HIMAGELIST /// A handle to the image list to query. /// /// /// When this method returns, contains the interface pointer requested. This is normally IImageList2, which provides the /// Initialize method. /// [PInvokeData("Commctrl.h")] #if !NETSTANDARD2_0 public static TIntf HIMAGELIST_QueryInterface(HIMAGELIST himl) => !himl.IsNull ? (TIntf)Marshal.GetTypedObjectForIUnknown((IntPtr)himl, typeof(TIntf)) : throw new ArgumentNullException(nameof(himl)); #else public static TIntf HIMAGELIST_QueryInterface(HIMAGELIST himl) { if (himl.IsNull) throw new ArgumentNullException(nameof(himl)); HIMAGELIST_QueryInterface(himl, typeof(TIntf).GUID, out var ppv).ThrowIfFailed(); return (TIntf)ppv; } #endif /// Get an image list handle from an image list interface. /// /// Type: HIMAGELIST /// An IImageList object. /// /// An image list handle. public static HIMAGELIST IImageListToHIMAGELIST(IImageList himl) => Marshal.GetIUnknownForObject(himl); /// Creates a single instance of an imagelist and returns an interface pointer to it. /// /// Type: REFCLSID /// A reference to the CLSID—a GUID that identifies the COM object to be created. This should be CLSID_ImageList. /// /// /// Type: const IUnknown* /// /// A pointer to the outer IUnknown interface that aggregates the object created by this function, or NULL if no /// aggregation is desired. /// /// /// /// Type: REFIID /// Reference to the desired interface ID. /// /// /// Type: void** /// /// When this method returns, contains the interface pointer requested in riid. This is normally IImageList2, which provides /// the Initialize method. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // HRESULT ImageList_CoCreateInstance( _In_ REFCLSID rclsid, _In_opt_ const IUnknown *punkOuter, _In_ REFIID riid, _Out_ void **ppv); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761518(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("CommonControls.h", MSDNShortId = "bb761518")] public static extern HRESULT ImageList_CoCreateInstance(in Guid rclsid, [MarshalAs(UnmanagedType.IUnknown)] object punkOuter, in Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Creates a new image list. /// /// Type: int /// The width, in pixels, of each image. /// /// /// Type: int /// The height, in pixels, of each image. /// /// /// Type: UINT /// /// A set of bit flags that specify the type of image list to create. This parameter can be a combination of the Image List /// Creation Flags. /// /// /// /// Type: int /// The number of images that the image list initially contains. /// /// /// Type: int /// /// The number of images by which the image list can grow when the system needs to make room for new images. This parameter /// represents the number of new images that the resized image list can contain. /// /// /// /// Type: HIMAGELIST /// Returns the handle to the image list if successful, or NULL otherwise. /// // HIMAGELIST ImageList_Create( int cx, int cy, UINT flags, int cInitial, int cGrow); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761522(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761522")] public static extern SafeHIMAGELIST ImageList_Create(int cx, int cy, ILC flags, int cInitial, int cGrow); /// Destroys an image list. /// /// Type: HIMAGELIST /// A handle to the image list to destroy. /// /// /// Type: BOOL /// Returns nonzero if successful, or zero otherwise. /// // BOOL ImageList_Destroy( _In_opt_ HIMAGELIST himl); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761524(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761524")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ImageList_Destroy(HIMAGELIST himl); /// Creates a duplicate of an existing image list. /// /// Type: HIMAGELIST /// /// A handle to the image list to be duplicated. All information contained in the original image list for normal images is copied to /// the new image list. Overlay images are not copied. /// /// /// /// Type: HIMAGELIST /// Returns the handle to the new duplicate image list if successful, or NULL otherwise. /// // HIMAGELIST ImageList_Duplicate( HIMAGELIST himl); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761540(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761540")] public static extern SafeHIMAGELIST ImageList_Duplicate(HIMAGELIST himl); /// Creates an icon from an image and mask in an image list. /// /// Type: HIMAGELIST /// A handle to the image list. /// /// /// Type: int /// An index of the image. /// /// /// Type: UINT /// /// A combination of flags that specify the drawing style. For a list of values, see the description of the fStyle parameter of the /// ImageList_Draw function. /// /// /// /// Type: HICON /// Returns the handle to the icon if successful, or NULL otherwise. /// // HICON ImageList_GetIcon( HIMAGELIST himl, int i, UINT flags); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761548(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761548")] public static extern SafeHICON ImageList_GetIcon(HIMAGELIST himl, int i, IMAGELISTDRAWFLAGS flags); /// Creates an image list from the specified bitmap. /// /// Type: HINSTANCE /// /// A handle to the instance that contains the resource. This parameter can be NULL if you are loading an image from a file or /// loading an OEM resource. /// /// /// /// Type: LPCTSTR /// The image to load. /// /// If the uFlags parameter includes LR_LOADFROMFILE, lpbmp is the address of a null-terminated string that names the file containing /// the image to load. /// /// /// If the hi parameter is non- NULL and LR_LOADFROMFILE is not specified, lpbmp is the address of a null-terminated string /// that contains the name of the image resource in the hi module. /// /// /// If hi is NULL and LR_LOADFROMFILE is not specified, the LOWORD of this parameter must be the identifier of an OEM /// image to load. To create this value, use the MAKEINTRESOURCE macro with one of the OEM image identifiers defined in /// Winuser.h. These identifiers have the following prefixes. /// /// /// /// /// Value /// Meaning /// /// /// OBM_ for OEM bitmaps /// /// /// /// OIC_ for OEM icons /// /// /// /// OCR_ for OEM cursors /// /// /// /// /// /// /// Type: int /// /// The width of each image. The height of each image and the initial number of images are inferred by the dimensions of the /// specified resource. /// /// /// /// Type: int /// /// The number of images by which the image list can grow when the system needs to make room for new images. This parameter /// represents the number of new images that the resized image list can contain. /// /// /// /// Type: COLORREF /// /// The color used to generate a mask. Each pixel of this color in the specified bitmap, cursor, or icon is changed to black, and the /// corresponding bit in the mask is set to 1. If this parameter is the CLR_NONE value, no mask is generated. If this parameter is /// the CLR_DEFAULT value, the color of the pixel at the upper-left corner of the image is treated as the mask color. /// /// /// /// Type: UINT /// /// A flag that specifies the type of image to load. This parameter must be IMAGE_BITMAP to indicate that a bitmap is being loaded. /// /// /// /// /// Value /// Meaning /// /// /// IMAGE_BITMAP /// Loads a bitmap. /// /// /// /// /// /// Type: UINT /// Flags that specify how to load the image. This parameter can be a combination of the following values. /// /// /// /// Value /// Meaning /// /// /// LR_CREATEDIBSECTION /// /// Causes the function to return a DIB section bitmap rather than a compatible bitmap when the uType parameter specifies /// IMAGE_BITMAP. LR_CREATEDIBSECTION is useful for loading a bitmap without mapping it to the colors of the display device. /// /// /// /// LR_DEFAULTCOLOR /// Uses the color format of the display. /// /// /// LR_DEFAULTSIZE /// /// Uses the width or height specified by the system metric values for cursors and icons if the cx parameter is set to zero. If this /// value is not specified and cx is set to zero, the function sets the size to the one specified in the resource. If the resource /// contains multiple images, the function sets the size to that of the first image. /// /// /// /// LR_LOADFROMFILE /// Loads the image from the file specified by the lpbmp parameter. /// /// /// LR_LOADMAP3DCOLORS /// /// Searches the color table for the image and replaces the following shades of gray with the corresponding three-dimensional color: /// Dk Gray: RGB(128, 128, 128)COLOR_3DSHADOW Gray: RGB(192, 192, 192)COLOR_3DFACE Lt Gray: RGB(223, 223, 223)COLOR_3DLIGHT For more /// information, see the Remarks section. /// /// /// /// LR_LOADTRANSPARENT /// /// Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the /// default window color (the COLOR_WINDOW display color). All pixels in the image that use that color become the default window /// value color. This value applies only to images that have a corresponding color table. For more information, see the Remarks section. /// /// /// /// LR_MONOCHROME /// Loads the image in black and white. /// /// /// LR_SHARED /// /// Shares the image handle if the image is loaded multiple times. Do not use this value for images that have nontraditional sizes /// that might change after loading or for images that are loaded from a file. /// /// /// /// /// /// /// Type: HIMAGELIST /// Returns the handle to the image list if successful, or NULL otherwise. /// // HIMAGELIST ImageList_LoadImage( HINSTANCE hi, LPCTSTR lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761557(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761557")] public static extern SafeHIMAGELIST ImageList_LoadImage(HINSTANCE hi, string lpbmp, int cx, int cGrow, COLORREF crMask, LoadImageType uType, LoadImageOptions uFlags); /// Reads an image list from a stream. /// /// Type: LPSTREAM /// A pointer to the stream. /// /// /// Type: HIMAGELIST /// Returns the handle to the image list if successful, or NULL otherwise. /// // HIMAGELIST ImageList_Read( LPSTREAM pstm); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761560(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761560")] public static extern SafeHIMAGELIST ImageList_Read(IStream pstm); /// Reads an image list from a stream, and returns an IImageList interface to the image list. /// /// Type: DWORD /// A flag that specifies how the stream is read. /// /// /// /// Value /// Meaning /// /// /// ILP_NORMAL /// Expects an image list that was written with the ILP_NORMAL flag specified. /// /// /// ILP_DOWNLEVEL /// Expects an image list that was written with the ILP_DOWNLEVEL flag specified. /// /// /// /// /// /// Type: LPSTREAM /// The address of the stream. /// /// /// Type: REFIID /// An IID for the image list. /// /// /// Type: void** /// The address of a pointer to the interface for the image list if successful, NULL otherwise. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // HRESULT ImageList_ReadEx( _In_ DWORD dwFlags, _In_ LPSTREAM pstm, _Out_ REFIID riid, _Out_ void **ppv); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761562(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb761562")] public static extern void ImageList_ReadEx(ILP dwFlags, IStream pstm, out Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Writes an image list to a stream. /// /// Type: HIMAGELIST /// A handle to the image list. /// /// /// Type: LPSTREAM /// A pointer to the stream. /// /// /// Type: BOOL /// Returns nonzero if successful, or zero otherwise. /// // BOOL ImageList_Write( HIMAGELIST himl, LPSTREAM pstm); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775228(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb775228")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ImageList_Write(HIMAGELIST himl, IStream pstm); /// Writes an image list to a stream. /// /// Type: HIMAGELIST /// A handle to the image list. /// /// /// Type: DWORD /// A flag that specifies how the stream is written. /// /// /// /// Value /// Meaning /// /// /// ILP_NORMAL /// /// Writes to the stream using the file format for Common Controls 6.0, which includes information about image list attributes new to /// this version. /// /// /// /// ILP_DOWNLEVEL /// /// Writes to the stream using a file format previous to version 6.0. Specify this flag if you need to save image lists loaded under /// Common Controls versions earlier than version 6.0. /// /// /// /// /// /// /// Type: LPSTREAM /// The address of the stream. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // HRESULT ImageList_WriteEx( _In_ HIMAGELIST himl, _In_ DWORD dwFlags, _In_ LPSTREAM pstm); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775229(v=vs.85).aspx [DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Commctrl.h", MSDNShortId = "bb775229")] public static extern HRESULT ImageList_WriteEx(HIMAGELIST himl, ILP dwFlags, IStream pstm); /// Prepares the index of an overlay mask so that the ImageList_Draw function can use it. /// /// Type: UINT /// An index of an overlay mask. /// /// No return value. // UINT INDEXTOOVERLAYMASK( UINT iOverlay); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761408(v=vs.85).aspx [PInvokeData("Commctrl.h", MSDNShortId = "bb761408")] public static int INDEXTOOVERLAYMASK(int iOverlay) => iOverlay << 8; /// Sets the dimensions of images in an image list and removes all images from the list. /// The instance. /// /// A value that contains the width and height, in pixels, of the images in the image list. All images in an image list have the same dimensions. /// public static void SetIconSize(this IImageList il, SIZE size) => il.SetIconSize(size.Width, size.Height); /// Contains information about an image in an image list. This structure is used with the IImageList::GetImageInfo function. [PInvokeData("Commctrl.h", MSDNShortId = "bb761393")] [StructLayout(LayoutKind.Sequential)] public struct IMAGEINFO { /// A handle to the bitmap that contains the images. public HBITMAP hbmImage; /// /// A handle to a monochrome bitmap that contains the masks for the images. If the image list does not contain a mask, this /// member is NULL. /// public HBITMAP hbmMask; /// Not used. This member should always be zero. public int Unused1; /// Not used. This member should always be zero. public int Unused2; /// The bounding rectangle of the specified image within the bitmap specified by hbmImage. public RECT rcImage; } /// Contains image list statistics. Used by GetStatistics. // typedef struct tagIMAGELISTSTATS { DWORD cbSize; int cAlloc; int cUsed; int cStandby;} IMAGELISTSTATS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb761397(v=vs.85).aspx [PInvokeData("Commoncontrols.h", MSDNShortId = "bb761397")] [StructLayout(LayoutKind.Sequential)] public struct IMAGELISTSTATS { /// /// Type: DWORD /// The image list size. /// public uint cbSize; /// /// Type: int /// The number of images allocated. /// public int cAlloc; /// /// Type: int /// The number of images in use. /// public int cUsed; /// /// Type: int /// The number of standby images. /// public int cStandby; } /// Image list class. [ComImport, Guid("7C476BA2-02B1-48f4-8048-B24619DDC058"), ClassInterface(ClassInterfaceType.None)] [PInvokeData("CommonControls.h")] public class CImageList { } /// Contains information about an image list draw operation and is used with the IImageList::Draw function. // typedef struct _IMAGELISTDRAWPARAMS { DWORD cbSize; HIMAGELIST himl; int i; HDC hdcDst; int x; int y; int cx; int cy; int xBitmap; // int yBitmap; COLORREF rgbBk; COLORREF rgbFg; UINT fStyle; DWORD dwRop; DWORD fState; DWORD Frame; DWORD crEffect;} // IMAGELISTDRAWPARAMS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb761395(v=vs.85).aspx [PInvokeData("Commctrl.h", MSDNShortId = "bb761395")] [StructLayout(LayoutKind.Sequential)] public class IMAGELISTDRAWPARAMS { /// The size of this structure, in bytes. public int cbSize; /// A handle to the image list that contains the image to be drawn. public HIMAGELIST himl; /// The zero-based index of the image to be drawn. public int i; /// A handle to the destination device context. public HDC hdcDst; /// The x-coordinate that specifies where the image is drawn. public int x; /// The y-coordinate that specifies where the image is drawn. public int y; /// /// A value that specifies the number of pixels to draw, relative to the upper-left corner of the drawing operation as specified /// by xBitmap and yBitmap. If cx and cy are zero, then Draw draws the entire valid section. The method does not ensure that the /// parameters are valid. /// public int cx; /// /// A value that specifies the number of pixels to draw, relative to the upper-left corner of the drawing operation as specified /// by xBitmap and yBitmap. If cx and cy are zero, then Draw draws the entire valid section. The method does not ensure that the /// parameters are valid. /// public int cy; /// /// The x-coordinate that specifies the upper-left corner of the drawing operation in reference to the image itself. Pixels of /// the image that are to the left of xBitmap and above yBitmap do not appear. /// public int xBitmap; /// /// The y-coordinate that specifies the upper-left corner of the drawing operation in reference to the image itself. Pixels of /// the image that are to the left of xBitmap and above yBitmap do not appear. /// public int yBitmap; /// /// The image background color. This parameter can be an application-defined RGB value or or . /// public COLORREF rgbBk; /// /// The image foreground color. This member is used only if fStyle includes the ILD_BLEND25 or ILD_BLEND50 flag. This parameter /// can be an application-defined RGB value or or . /// public COLORREF rgbFg; /// /// A flag specifying the drawing style and, optionally, the overlay image. See the comments section at the end of this topic for /// information on the overlay image. This member can contain one or more image list drawing flags. /// public IMAGELISTDRAWFLAGS fStyle; /// /// A value specifying a raster operation code. These codes define how the color data for the source rectangle will be combined /// with the color data for the destination rectangle to achieve the final color. This member is ignored if fStyle does not /// include the ILD_ROP flag. /// public RasterOperationMode dwRop; /// /// A flag that specifies the drawing state. This member can contain one or more image list state flags. You must use /// comctl32.dll version 6 to use this member. /// public IMAGELISTSTATEFLAGS fState; /// /// Used with the alpha blending effect. /// /// When used with ILS_ALPHA, this member holds the value for the alpha channel. This value can be from 0 to 255, with 0 being /// completely transparent, and 255 being completely opaque. /// /// You must use comctl32.dll version 6 to use this member. See the Remarks. /// public uint Frame; /// /// A color used for the glow and shadow effects. You must use comctl32.dll version 6 to use this member. See the Remarks. /// public COLORREF crEffect; /// Initializes a new instance of the class. public IMAGELISTDRAWPARAMS() => cbSize = Marshal.SizeOf(this); /// Initializes a new instance of the class. /// A handle to the destination device context. /// The bounds that specifiy where the image is drawn. /// The zero-based index of the image to be drawn. /// The image background color. /// A flag specifying the drawing style and, optionally, the overlay image. public IMAGELISTDRAWPARAMS(HDC hdcDst, RECT bounds, int index, COLORREF bgColor, IMAGELISTDRAWFLAGS style = IMAGELISTDRAWFLAGS.ILD_NORMAL) : this() { i = index; this.hdcDst = hdcDst; x = bounds.X; y = bounds.Y; cx = bounds.Width; cy = bounds.Height; rgbBk = bgColor; fStyle = style; } } /// /// Safe image list handle. Be aware that if this is instantiated with ownership of the handle, it will be destroyed on disposal. /// public class SafeHIMAGELIST : SafeHANDLE { private IImageList iImageList; /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// public SafeHIMAGELIST(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } private SafeHIMAGELIST() : base() { } /// Gets a safe HIMAGELIST handle from an instance. /// An IImageList object. /// A safe HIMAGELIST handle. public static SafeHIMAGELIST FromIImageList(IImageList iil) => ImageList_Duplicate(IImageListToHIMAGELIST(iil)); /// Gets the IImageList interface for this handle. /// The interface. public IImageList Interface => iImageList ?? (iImageList = HIMAGELIST_QueryInterface(handle)); /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. public static implicit operator HIMAGELIST(SafeHIMAGELIST h) => h.handle; /// protected override bool InternalReleaseHandle() => ImageList_Destroy(this); } } }