CImageList* pImageList = new CImageList();
pImageList->Create(80,80,ILC_COLORDDB,10,1);
///////动态改变
ImageList_SetIconSize(pImageList->m_hImageList,30,30);
////////////////////////////////////////////
class CImageList
{
public:
HIMAGELIST m_hImageList;
// Constructor
CImageList(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList)
{ }
// Operators, etc.
CImageList& operator =(HIMAGELIST hImageList)
{
m_hImageList = hImageList;
return *this;
}
operator HIMAGELIST() const { return m_hImageList; }
void Attach(HIMAGELIST hImageList)
{
ATLASSERT(m_hImageList == NULL);
ATLASSERT(hImageList != NULL);
m_hImageList = hImageList;
}
HIMAGELIST Detach()
{
HIMAGELIST hImageList = m_hImageList;
m_hImageList = NULL;
return hImageList;
}
bool IsNull() const { return (m_hImageList == NULL); }
// Attributes
int GetImageCount() const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetImageCount(m_hImageList);
}
COLORREF GetBkColor() const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetBkColor(m_hImageList);
}
COLORREF SetBkColor(COLORREF cr)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetBkColor(m_hImageList, cr);
}
BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo);
}
HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIcon(m_hImageList, nIndex, uFlags);
}
BOOL GetIconSize(int& cx, int& cy) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIconSize(m_hImageList, &cx, &cy);
}
BOOL GetIconSize(SIZE& size) const
{
ATLASSERT(m_hImageList != NULL);
return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy);
}
BOOL SetIconSize(int cx, int cy)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetIconSize(m_hImageList, cx, cy);
}
BOOL SetIconSize(SIZE size)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetIconSize(m_hImageList, size.cx, size.cy);
}
BOOL SetImageCount(UINT uNewCount)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetImageCount(m_hImageList, uNewCount);
}
BOOL SetOverlayImage(int nImage, int nOverlay)
{
ATLASSERT(m_hImageList != NULL);
return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay);
}