1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#include "Mra.h"
#include "MraIcons.h"
void CMraProto::AddIcoLibItems(LPWSTR lpwszRootSectionName, LPWSTR lpwszSubSectionName, const GUI_DISPLAY_ITEM *pgdiItems, size_t dwCount, HANDLE *hResult)
{
char szBuff[MAX_PATH];
WCHAR wszSection[MAX_PATH], wszPath[MAX_FILEPATH];
SKINICONDESC sid = {0};
sid.cbSize = sizeof(sid);
sid.pwszSection = wszSection;
sid.pwszDefaultFile = wszPath;
sid.cx = sid.cy = 16;
sid.flags = SIDF_ALL_UNICODE;
if (lpwszSubSectionName == NULL) lpwszSubSectionName = L"";
GetModuleFileName(masMraSettings.hInstance, wszPath, SIZEOF(wszPath));
mir_sntprintf(wszSection, SIZEOF(wszSection), L"%s%s%s", lpwszRootSectionName, m_tszUserName, lpwszSubSectionName);
for (size_t i = 0;i<dwCount;i++) {
mir_snprintf(szBuff, SIZEOF(szBuff), "%s_%s", m_szModuleName, pgdiItems[i].lpszName);
sid.pszName = szBuff;
sid.pwszDescription = pgdiItems[i].lpwszDescr;
sid.iDefaultIndex = -pgdiItems[i].defIcon;
sid.hDefaultIcon = (HICON)LoadImage(masMraSettings.hInstance, MAKEINTRESOURCE(pgdiItems[i].defIcon), IMAGE_ICON, 0, 0, LR_SHARED);
if (sid.hDefaultIcon == NULL) sid.hDefaultIcon = (HICON)LoadImage(NULL, MAKEINTRESOURCE(pgdiItems[i].defIcon), IMAGE_ICON, 0, 0, LR_SHARED);
hResult[i] = Skin_AddIcon(&sid);
}
}
HICON IconLibGetIcon(HANDLE hIcon)
{
return IconLibGetIconEx(hIcon, LR_SHARED);
}
HICON IconLibGetIconEx(HANDLE hIcon, DWORD dwFlags)
{
HICON hiIcon = NULL;
if (hIcon) {
hiIcon = Skin_GetIconByHandle(hIcon);
if ((dwFlags & LR_SHARED) == 0)
hiIcon = CopyIcon(hiIcon);
}
return hiIcon;
}
//////////////////////////////////////////////////////////////////////////////////////
void CMraProto::IconsLoad()
{
AddIcoLibItems(L"Protocols/", L"/MainMenu", gdiMenuItems, gdiMenuItemsCount, hMainMenuIcons);
AddIcoLibItems(L"Protocols/", L"/ContactMenu", gdiContactMenuItems, gdiContactMenuItemsCount, hContactMenuIcons);
// Advanced Status Icons initialization
AddIcoLibItems(L"Protocols/", L"/Extra status", gdiExtraStatusIconsItems, gdiExtraStatusIconsItemsCount, hAdvancedStatusIcons);
}
void CMraProto::IconsUnLoad()
{
// Advanced Status Icons initialization
bzero(hAdvancedStatusIcons, sizeof(hAdvancedStatusIcons));
bzero(hAdvancedStatusItems, sizeof(hAdvancedStatusItems));
}
void CMraProto::InitXStatusIcons()
{
int iCurIndex;
char szBuff[MAX_PATH];
WCHAR wszSection[MAX_PATH], wszPath[MAX_FILEPATH];
SKINICONDESC sid = {0};
sid.cbSize = sizeof(sid);
sid.pwszSection = wszSection;
sid.pwszDefaultFile = wszPath;
sid.cx = sid.cy = 16;
sid.flags = SIDF_ALL_UNICODE;
if (masMraSettings.hDLLXStatusIcons)
GetModuleFileName(masMraSettings.hDLLXStatusIcons, wszPath, SIZEOF(wszPath));
else
bzero(wszPath, sizeof(wszPath));
mir_sntprintf(wszSection, SIZEOF(wszSection), L"Status Icons/%s/Custom Status", m_tszUserName);
hXStatusAdvancedStatusIcons[0] = NULL;
for (size_t i = 1; i < MRA_XSTATUS_COUNT+1; i++) {
mir_snprintf(szBuff, SIZEOF(szBuff), "%s_xstatus%ld", m_szModuleName, i);
iCurIndex = (IDI_XSTATUS1-1+i);
sid.pszName = szBuff;
sid.pwszDescription = lpcszXStatusNameDef[i];
sid.iDefaultIndex = -iCurIndex;
if (masMraSettings.hDLLXStatusIcons)
sid.hDefaultIcon = (HICON)LoadImage(masMraSettings.hDLLXStatusIcons, MAKEINTRESOURCE(iCurIndex), IMAGE_ICON, 0, 0, LR_SHARED);
else
sid.hDefaultIcon = NULL;
hXStatusAdvancedStatusIcons[i] = Skin_AddIcon(&sid);
}
}
void CMraProto::DestroyXStatusIcons()
{
char szBuff[MAX_PATH];
for (size_t i = 1; i < MRA_XSTATUS_COUNT+1; i++) {
mir_snprintf(szBuff, SIZEOF(szBuff), "xstatus%ld", i);
Skin_RemoveIcon(szBuff);
}
bzero(hXStatusAdvancedStatusIcons, sizeof(hXStatusAdvancedStatusIcons));
bzero(hXStatusAdvancedStatusItems, sizeof(hXStatusAdvancedStatusItems));
}
|