summaryrefslogtreecommitdiff
path: root/plugins/Utils/mir_icons.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-19 22:48:01 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-19 22:48:01 +0000
commit95aa036670a1ce2c461ffd9bd3a586d191ee4675 (patch)
treecd244db18622df3462166ed39593ca924c890f6b /plugins/Utils/mir_icons.cpp
parentf6e0db0590e2f8feeacc29d4e50007fbe358f9d5 (diff)
- various icolib fixes;
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@1061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils/mir_icons.cpp')
-rw-r--r--plugins/Utils/mir_icons.cpp46
1 files changed, 16 insertions, 30 deletions
diff --git a/plugins/Utils/mir_icons.cpp b/plugins/Utils/mir_icons.cpp
index bab0674d35..00adda0614 100644
--- a/plugins/Utils/mir_icons.cpp
+++ b/plugins/Utils/mir_icons.cpp
@@ -29,15 +29,11 @@ extern HINSTANCE hInst;
HICON IcoLib_LoadIcon(const char *iconName, BOOL copy)
{
- if (!ServiceExists(MS_SKIN2_GETICON))
- return NULL;
-
if (iconName == NULL || iconName[0] == 0)
return NULL;
HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) iconName);
- if (copy && hIcon != NULL)
- {
+ if (copy && hIcon != NULL) {
hIcon = CopyIcon(hIcon);
CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
}
@@ -46,40 +42,30 @@ HICON IcoLib_LoadIcon(const char *iconName, BOOL copy)
void IcoLib_ReleaseIcon(const char *iconName)
{
- if (ServiceExists(MS_SKIN2_RELEASEICON))
- CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM) iconName);
+ CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM) iconName);
}
-
void IcoLib_ReleaseIcon(HICON hIcon)
{
- if (ServiceExists(MS_SKIN2_RELEASEICON))
- CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
+ CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
}
-
-HANDLE IcoLib_Register(char *name, TCHAR *section, TCHAR *description, int id)
+HANDLE IcoLib_Register(char *name, char *section, char *description, int id)
{
- HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) name);
- if (hIcon != NULL) {
- CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
- return NULL;
- }
+ HANDLE hIcon = Skin_GetIconHandle(name);
+ if (hIcon != NULL)
+ return hIcon;
+
+ TCHAR tszFile[MAX_PATH];
+ GetModuleFileName(hInst, tszFile, MAX_PATH);
SKINICONDESC sid = {0};
sid.cbSize = sizeof(SKINICONDESC);
- sid.flags = SIDF_TCHAR;
+ sid.flags = SIDF_PATH_TCHAR;
sid.pszName = name;
- sid.ptszSection = section;
- sid.ptszDescription = description;
-
- int cx = GetSystemMetrics(SM_CXSMICON);
- sid.hDefaultIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, cx, cx, LR_DEFAULTCOLOR | LR_SHARED);
- HANDLE hRes = Skin_AddIcon(&sid);
-
- if (sid.hDefaultIcon)
- DestroyIcon(sid.hDefaultIcon);
-
- return hRes;
+ sid.pszSection = section;
+ sid.pszDescription = description;
+ sid.ptszDefaultFile = tszFile;
+ sid.iDefaultIndex = -id;
+ return Skin_AddIcon(&sid);
}
-