summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/loadicons.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
commit48540940b6c28bb4378abfeb500ec45a625b37b6 (patch)
tree2ef294c0763e802f91d868bdef4229b6868527de /plugins/SecureIM/loadicons.cpp
parent5c350913f011e119127baeb32a6aedeb4f0d33bc (diff)
initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM/loadicons.cpp')
-rw-r--r--plugins/SecureIM/loadicons.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/plugins/SecureIM/loadicons.cpp b/plugins/SecureIM/loadicons.cpp
new file mode 100644
index 0000000000..1b9d4735bd
--- /dev/null
+++ b/plugins/SecureIM/loadicons.cpp
@@ -0,0 +1,104 @@
+#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;
+ memset(&sid,0,sizeof(sid));
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.pszSection = "SecureIM";
+
+ HICON hIcon;
+ for (int i=0; icons[i].key; i++) {
+ if(ServiceExists(MS_SKIN2_ADDICON)) {
+ 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);
+ CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name);
+ }
+ else {
+ hIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED);
+ }
+ 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;
+ }
+
+ if(ServiceExists(MS_SKIN2_ADDICON)) {
+ AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+ }
+}
+
+// EOF