Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.7 KiB

  1. //*******************************************************************************************
  2. //
  3. // Filename : XIcon.h
  4. //
  5. // defines for CImageList and CXIcon
  6. //
  7. // Copyright (c) 1994 - 1996 Microsoft Corporation. All rights reserved
  8. //
  9. //*******************************************************************************************
  10. #ifndef _XICON_H_
  11. #define _XICON_H_
  12. class CImageList
  13. {
  14. public:
  15. CImageList() : m_himl(NULL) {}
  16. ~CImageList() {if (m_himl) ImageList_Destroy(m_himl);}
  17. operator HIMAGELIST() {return(m_himl);}
  18. BOOL Create(int cx, int cy, int cGrow)
  19. {
  20. m_himl = ImageList_Create(cx, cy, ILC_MASK, cGrow, cGrow);
  21. return(m_himl != NULL);
  22. }
  23. private:
  24. HIMAGELIST m_himl;
  25. } ;
  26. class CXIcon
  27. {
  28. public:
  29. CXIcon() {}
  30. ~CXIcon() {}
  31. BOOL Init(HWND hwndLB, UINT idiDef);
  32. CImageList& GetIML(BOOL bLarge) {return(bLarge ? m_cimlLg : m_cimlSm);}
  33. enum
  34. {
  35. AI_LARGE = 0x0001,
  36. AI_SMALL = 0x0002,
  37. } ;
  38. int AddIcon(HICON hIcon, UINT uFlags=AI_LARGE|AI_SMALL)
  39. {
  40. int i = -1;
  41. if (uFlags & AI_LARGE)
  42. {
  43. i = ImageList_AddIcon(m_cimlLg, hIcon);
  44. }
  45. if (uFlags & AI_SMALL)
  46. {
  47. i = ImageList_AddIcon(m_cimlSm, hIcon);
  48. }
  49. return(i);
  50. }
  51. int GetIcon(IShellFolder *psf, LPCITEMIDLIST pidl);
  52. private:
  53. int GetCachedIndex(LPCTSTR szIconFile, int iIndex, UINT wFlags);
  54. int CacheIcons(HICON hiconLarge, HICON hiconSmall,
  55. LPCTSTR szIconFile, int iIndex, UINT wFlags);
  56. static HRESULT ExtractIcon(LPCTSTR szIconFile, int iIndex, UINT wFlags,
  57. HICON *phiconLarge, HICON *phiconSmall, DWORD dwSizes);
  58. static UINT GetIDString(LPTSTR pszIDString, UINT uIDLen,
  59. LPCTSTR szIconFile, int iIndex, UINT wFlags);
  60. HWND m_hwndLB;
  61. CImageList m_cimlLg;
  62. CImageList m_cimlSm;
  63. } ;
  64. #endif // _XICON_H_