summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/loadicons.cpp
blob: 330342462661d5384fb5bf2f18d7e7e420defe9c (plain)
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
#include "commonheaders.h"


HINSTANCE LoadIconsPack(const char* szIconsPack)
{
	HINSTANCE hNewIconInst = NULL;
	WORD i;

	hNewIconInst = LoadLibrary(szIconsPack);

	if (hNewIconInst != NULL)
	{
		for(i=ID_FIRSTICON; i<=ID_LASTICON; i++)
			if (LoadIcon(hNewIconInst, MAKEINTRESOURCE(i)) == NULL)
			{
				FreeLibrary(hNewIconInst);
				hNewIconInst = NULL;
				break;
			}
	}
	return hNewIconInst;
}



int ReloadIcons(WPARAM wParam, LPARAM lParam)
{
	HICON hIcon;
	for (int i=0; icons[i].key; i++) {
		hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name);
		if(icons[i].tbl == TBL_IEC)
			g_hIEC[icons[i].idx]=hIcon;
		else
		if(icons[i].tbl == TBL_ICO)
			g_hICO[icons[i].idx]=hIcon;
		else
		if(icons[i].tbl == TBL_POP)
			g_hPOP[icons[i].idx]=hIcon;
	}

	return 0;
}


void InitIcons(void)
{
	HINSTANCE hNewIconInst = NULL;

	if ( g_hFolders ) {
		LPSTR pathname = (LPSTR) alloca(MAX_PATH);
		FoldersGetCustomPathEx(g_hFolders, pathname, MAX_PATH, "icons\\", "secureim_icons.dll");
		if (hNewIconInst == NULL)
			hNewIconInst = LoadIconsPack(pathname);
	}

	if (hNewIconInst == NULL)
		hNewIconInst = LoadIconsPack("icons\\secureim_icons.dll");

	if (hNewIconInst == NULL)
		hNewIconInst = LoadIconsPack("plugins\\secureim_icons.dll");

	if (hNewIconInst == NULL)
		g_hIconInst = g_hInst;
	else
		g_hIconInst = hNewIconInst;


	SKINICONDESC sid = { 0 };
	sid.cbSize = sizeof(sid);
	sid.pszSection = "SecureIM";

	HICON hIcon;
	for (int i=0; icons[i].key; i++) {
		sid.pszSection = icons[i].section;
		sid.pszName = icons[i].name;
		sid.pszDescription = icons[i].text;
		sid.pszDefaultFile = "secureim_icons.dll";
		sid.iDefaultIndex = icons[i].key;
		sid.hDefaultIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED);
		Skin_AddIcon(&sid);
		hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name);

		if(icons[i].tbl == TBL_IEC)
			g_hIEC[icons[i].idx]=hIcon;
		else
		if(icons[i].tbl == TBL_ICO)
			g_hICO[icons[i].idx]=hIcon;
		else
		if(icons[i].tbl == TBL_POP)
			g_hPOP[icons[i].idx]=hIcon;
	}

	AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons);
}

// EOF