// CommonControls.idl
//
cpp_quote("#if (_WIN32_IE >= 0x0501)")

import "oaidl.idl";
import "ocidl.idl";

cpp_quote("#ifndef WINCOMMCTRLAPI")
cpp_quote("#if !defined(_COMCTL32_) && defined(_WIN32)")
cpp_quote("#define WINCOMMCTRLAPI DECLSPEC_IMPORT")
cpp_quote("#else")
cpp_quote("#define WINCOMMCTRLAPI")
cpp_quote("#endif")
cpp_quote("#endif // WINCOMMCTRLAPI")

cpp_quote("#ifdef MIDL_PASS")
typedef DWORD RGBQUAD;

typedef IUnknown* HIMAGELIST;
cpp_quote("typedef struct _IMAGELIST* HIMAGELIST;")

typedef struct _IMAGELISTDRAWPARAMS
{
    DWORD       cbSize;
    HIMAGELIST  himl;
    int         i;
    HDC         hdcDst;
    int         x;
    int         y;
    int         cx;
    int         cy;
    int         xBitmap;        // x offest from the upperleft of bitmap
    int         yBitmap;        // y offset from the upperleft of bitmap
    COLORREF    rgbBk;
    COLORREF    rgbFg;
    UINT        fStyle;
    DWORD       dwRop;
    DWORD       fState;
    DWORD       Frame;
    COLORREF    crEffect;
} IMAGELISTDRAWPARAMS;

typedef IMAGELISTDRAWPARAMS* LPIMAGELISTDRAWPARAMS;
typedef struct tagIMAGEINFO
{
    HBITMAP hbmImage;
    HBITMAP hbmMask;
    int     Unused1;
    int     Unused2;
    RECT    rcImage;
} IMAGEINFO;

typedef IMAGEINFO* LPIMAGEINFO;
cpp_quote("#endif") // MIDL_PASS

cpp_quote("#if _WIN32_WINNT >= 0x0600")

cpp_quote("WINCOMMCTRLAPI HRESULT WINAPI ImageList_CoCreateInstance(")
cpp_quote("         __in  REFCLSID rclsid,")
cpp_quote("     __in_opt  const IUnknown *punkOuter,")
cpp_quote("         __in  REFIID riid,")
cpp_quote("  __deref_out void **ppv);")
cpp_quote("#endif")

// flags returned by GetItemFlags
cpp_quote("#define ILIF_ALPHA               0x00000001") // item has alpha
cpp_quote("#define ILIF_LOWQUALITY          0x00000002") // image is low quality (was generated by a StretchBlt)

// return values (if SUCCEEDED()) for IImageList::Draw
cpp_quote("#define ILDRF_IMAGELOWQUALITY    0x00000001") // image is low quality
cpp_quote("#define ILDRF_OVERLAYLOWQUALITY  0x00000010") // overlay is low quality

[
    uuid(46EB5926-582E-4017-9FDF-E8998DAA0950),
    local
]
interface IImageList : IUnknown
{
    HRESULT Add([in, annotation("__in")] HBITMAP hbmImage, [in, unique, annotation("__in_opt")] HBITMAP hbmMask, [out, annotation("__out")] int* pi);
    HRESULT ReplaceIcon(int i, [in, annotation("__in")] HICON hicon, [out, annotation("__out")] int* pi);
    HRESULT SetOverlayImage(int iImage, int iOverlay);
    HRESULT Replace(int i, [in, annotation("__in")] HBITMAP hbmImage, [in, unique, annotation("__in_opt")] HBITMAP hbmMask);
    HRESULT AddMasked([in, annotation("__in")] HBITMAP hbmImage, COLORREF crMask, [out, annotation("__out")] int* pi);
    HRESULT Draw([in, annotation("__in")] IMAGELISTDRAWPARAMS* pimldp);
    HRESULT Remove(int i);
    HRESULT GetIcon(int i, UINT flags, [out, annotation("__out")] HICON* picon);
    HRESULT GetImageInfo(int i, [out, annotation("__out")] IMAGEINFO* pImageInfo);
    HRESULT Copy(int iDst, [in, annotation("__in")] IUnknown* punkSrc, int iSrc, UINT uFlags);
    HRESULT Merge(int i1, [in, annotation("__in")] IUnknown* punk2, int i2, int dx, int dy, REFIID riid, [out, iid_is(riid), annotation("__deref_out")] void** ppv);
    HRESULT Clone(REFIID riid, [out, iid_is(riid), annotation("__deref_out")] void** ppv);
    HRESULT GetImageRect(int i, [out, annotation("__out")] RECT* prc);
    HRESULT GetIconSize([out, annotation("__out")] int* cx, [out, annotation("__out")] int* cy);
    HRESULT SetIconSize(int cx, int cy);
    HRESULT GetImageCount([out, annotation("__out")] int* pi);
    HRESULT SetImageCount(UINT uNewCount);
    HRESULT SetBkColor(COLORREF clrBk, [out, annotation("__out")] COLORREF* pclr);
    HRESULT GetBkColor([out, annotation("__out")] COLORREF* pclr);
    HRESULT BeginDrag(int iTrack, int dxHotspot, int dyHotspot);
    HRESULT EndDrag();
    HRESULT DragEnter([in, unique, annotation("__in_opt")] HWND hwndLock, int x, int y);
    HRESULT DragLeave([in, unique, annotation("__in_opt")] HWND hwndLock);
    HRESULT DragMove(int x, int y);
    HRESULT SetDragCursorImage([in, annotation("__in")] IUnknown* punk, int iDrag, int dxHotspot, int dyHotspot);
    HRESULT DragShowNolock(BOOL fShow);
    HRESULT GetDragImage([out, annotation("__out_opt")] POINT * ppt, [out, annotation("__out_opt")] POINT * pptHotspot, REFIID riid, [out, iid_is(riid), annotation("__deref_out")] void** ppv);
    HRESULT GetItemFlags(int i, [out, annotation("__out")] DWORD *dwFlags);
    HRESULT GetOverlayImage(int iOverlay, [out, annotation("__out")] int* piIndex);
};


cpp_quote("#define ILR_DEFAULT                  0x0000")   

cpp_quote("#define ILR_HORIZONTAL_LEFT          0x0000")
cpp_quote("#define ILR_HORIZONTAL_CENTER        0x0001")
cpp_quote("#define ILR_HORIZONTAL_RIGHT         0x0002")

cpp_quote("#define ILR_VERTICAL_TOP             0x0000")
cpp_quote("#define ILR_VERTICAL_CENTER          0x0010")
cpp_quote("#define ILR_VERTICAL_BOTTOM          0x0020")

cpp_quote("#define ILR_SCALE_CLIP               0x0000")
cpp_quote("#define ILR_SCALE_ASPECTRATIO        0x0100")


// New for (_WIN32_IE >= 0x0605)
[
    uuid(192b9d83-50fc-457b-90a0-2b82a8b5dae1),
    local
]
interface IImageList2 : IImageList
{

//  Flags for GetOriginalSize
cpp_quote("#define ILGOS_ALWAYS         0x00000000") // always get the original size (can be slow)
cpp_quote("#define ILGOS_FROMSTANDBY    0x00000001") // only if present or on standby

//  Flags for ForceImagePresent
cpp_quote("#define ILFIP_ALWAYS         0x00000000") // always get the image (can be slow)
cpp_quote("#define ILFIP_FROMSTANDBY    0x00000001") // only if on standby

//  Flags for DiscardImages
//
//  ILDI_STANDBY and ILDI_PURGE are mutually exclusive.
//  ILDI_RESETACCESS can be combined with either.

cpp_quote("#define ILDI_PURGE       0x00000001") // discard and purge
cpp_quote("#define ILDI_STANDBY     0x00000002") // discard to standby list

cpp_quote("#define ILDI_RESETACCESS 0x00000004") // reset "has been accessed" flag
cpp_quote("#define ILDI_QUERYACCESS 0x00000008") // ask whether access flag is set (but do not reset)

    typedef struct tagIMAGELISTSTATS
    {
        DWORD       cbSize;
        int         cAlloc;     // number of images allocated
        int         cUsed;      // number of images in use
        int         cStandby;   // number of standby images
    } IMAGELISTSTATS;

    HRESULT Resize(int cxNewIconSize, int cyNewIconSize);
    HRESULT GetOriginalSize([in] int iImage, [in] DWORD dwFlags, [out, annotation("__out")] int *pcx, [out, annotation("__out")] int *pcy);
    HRESULT SetOriginalSize([in] int iImage, [in] int cx, [in] int cy);
    HRESULT SetCallback([in, unique, annotation("__in_opt")] IUnknown *punk);
    HRESULT GetCallback([in] REFIID riid, [out, iid_is(riid), annotation("__deref_out")] void** ppv);
    HRESULT ForceImagePresent([in] int iImage, DWORD dwFlags);
    HRESULT DiscardImages([in] int iFirstImage, [in] int iLastImage, [in] DWORD dwFlags);
    HRESULT PreloadImages([in, annotation("__in")] IMAGELISTDRAWPARAMS* pimldp);
    HRESULT GetStatistics([in, out, annotation("__inout")] IMAGELISTSTATS *pils);
    HRESULT Initialize([in] int cx, [in] int cy, [in] UINT flags, [in] int cInitial, [in] int cGrow);
    HRESULT Replace2([in] int i, [in, annotation("__in")] HBITMAP hbmImage, [in, unique, annotation("__in_opt")] HBITMAP hbmMask, [in, unique, annotation("__in_opt")] IUnknown *punk, [in] DWORD dwFlags);
    HRESULT ReplaceFromImageList([in] int i, [in, annotation("__in")] IImageList *pil, [in] int iSrc, [in, unique, annotation("__in_opt")] IUnknown *punk, [in] DWORD dwFlags);
};

[
    uuid(BCADA15B-B428-420c-8D28-023590924C9F)
]
library CommonControlObjects
{

    [
        uuid(7C476BA2-02B1-48f4-8048-B24619DDC058)  // CLSID_ImageList
    ]
    coclass ImageList
    {
        interface IImageList;
        interface IImageList2;
    }
};

cpp_quote("#endif // if (_WIN32_IE >= 0x0501)")

