summaryrefslogtreecommitdiff
path: root/Plugins/utils/mir_icons.cpp
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2009-05-02 00:08:17 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2009-05-02 00:08:17 +0000
commit7c52bd0b47d68806777152e097f1bf6f3f718170 (patch)
tree2b8bb05622141f9dff4a4fe1b53196b9860c2f1c /Plugins/utils/mir_icons.cpp
parent74de73a0d9a2a40ed77ac2ee6a2714ceb7c633b0 (diff)
utils: sync with berliOS
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@174 c086bb3d-8645-0410-b8da-73a8550f86e7
Diffstat (limited to 'Plugins/utils/mir_icons.cpp')
-rw-r--r--Plugins/utils/mir_icons.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/Plugins/utils/mir_icons.cpp b/Plugins/utils/mir_icons.cpp
index 1ee7999..a0d4939 100644
--- a/Plugins/utils/mir_icons.cpp
+++ b/Plugins/utils/mir_icons.cpp
@@ -24,14 +24,20 @@ Boston, MA 02111-1307, USA.
#include <m_system.h>
#include <m_icolib.h>
+extern HINSTANCE hInst;
-HICON LoadIconEx(const char *iconName, BOOL copy)
+
+
+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)
+ if (copy && hIcon != NULL)
{
hIcon = CopyIcon(hIcon);
CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM) iconName);
@@ -40,10 +46,35 @@ HICON LoadIconEx(const char *iconName, BOOL copy)
}
-void ReleaseIconEx(HICON hIcon)
+void IcoLib_ReleaseIcon(HICON hIcon)
{
if (ServiceExists(MS_SKIN2_RELEASEICON))
CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
- else
- DestroyIcon(hIcon);
}
+
+
+void IcoLib_Register(char *name, TCHAR *section, TCHAR *description, int id)
+{
+ HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) name);
+ if (hIcon != NULL)
+ {
+ CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
+ return;
+ }
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.flags = SIDF_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);
+
+ CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+
+ if (sid.hDefaultIcon)
+ DestroyIcon(sid.hDefaultIcon);
+}
+