1 // SysIconUtils.h
2
3 #ifndef __SYS_ICON_UTILS_H
4 #define __SYS_ICON_UTILS_H
5
6 #include "../../../Common/MyWindows.h"
7
8 #include <commctrl.h>
9
10 #include "../../../Common/MyString.h"
11
12 struct CExtIconPair
13 {
14 UString Ext;
15 int IconIndex;
16 // UString TypeName;
17
18 // int Compare(const CExtIconPair &a) const { return MyStringCompareNoCase(Ext, a.Ext); }
19 };
20
21 struct CAttribIconPair
22 {
23 DWORD Attrib;
24 int IconIndex;
25 // UString TypeName;
26
27 // int Compare(const CAttribIconPair &a) const { return Ext.Compare(a.Ext); }
28 };
29
30 class CExtToIconMap
31 {
32 public:
33 CRecordVector<CAttribIconPair> _attribMap;
34 CObjectVector<CExtIconPair> _extMap;
35 int SplitIconIndex;
36 int SplitIconIndex_Defined;
37
CExtToIconMap()38 CExtToIconMap(): SplitIconIndex_Defined(false) {}
39
Clear()40 void Clear()
41 {
42 SplitIconIndex_Defined = false;
43 _extMap.Clear();
44 _attribMap.Clear();
45 }
46 int GetIconIndex(DWORD attrib, const wchar_t *fileName /* , UString *typeName */);
47 // int GetIconIndex(DWORD attrib, const UString &fileName);
48 };
49
50 DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex);
51 int GetIconIndexForCSIDL(int csidl);
52
GetSysImageList(bool smallIcons)53 inline HIMAGELIST GetSysImageList(bool smallIcons)
54 {
55 SHFILEINFO shellInfo;
56 return (HIMAGELIST)SHGetFileInfo(TEXT(""),
57 FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY,
58 &shellInfo, sizeof(shellInfo),
59 SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
60 }
61
62 #endif
63