diff options
Diffstat (limited to 'updater/icons.cpp')
-rw-r--r-- | updater/icons.cpp | 70 |
1 files changed, 16 insertions, 54 deletions
diff --git a/updater/icons.cpp b/updater/icons.cpp index 9b8c3b5..1123294 100644 --- a/updater/icons.cpp +++ b/updater/icons.cpp @@ -1,10 +1,6 @@ #include "common.h"
#include "icons.h"
-HANDLE hIcoLibIconsChanged = NULL;
-
-extern HANDLE hMainMenuItem, hMainMenuItemRestart, hMainMenuItemUpdateAndExit;
-
typedef struct
{
char* szDescr;
@@ -12,83 +8,49 @@ typedef struct int defIconID;
} IconStruct;
-static IconStruct iconList[] =
+static const IconStruct iconList[] =
{
{ "Check for Plugin Updates", "updater_check", IDI_MAINMENU },
{ "Restart", "updater_restart", IDI_RESTART },
{ "Update and Exit", "updater_checkexit", IDI_UPDATEANDEXIT },
};
+HANDLE hIcolibIcon[SIZEOF(iconList)];
-HICON LoadIconEx(IconIndex i)
-{
- HICON hIcon;
- if (hIcoLibIconsChanged)
- hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconList[(int)i].szName);
- else
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(iconList[(int)i].defIconID),
- IMAGE_ICON, 0, 0, 0);
-
- return hIcon;
+HICON LoadIconEx(IconIndex i, bool big)
+{
+ return (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, big, (LPARAM)hIcolibIcon[(int)i]);
}
-void ReleaseIconEx(HICON hIcon)
+HANDLE GetIconHandle(IconIndex i)
{
- if (hIcoLibIconsChanged)
- CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
- else
- DestroyIcon(hIcon);
+ return hIcolibIcon[(int)i];
}
-
-int ReloadIcons(WPARAM wParam, LPARAM lParam)
+void ReleaseIconEx(HICON hIcon)
{
- // fix menu icons
- CLISTMENUITEM menu = {0};
-
- menu.cbSize = sizeof(menu);
- menu.flags = CMIM_ICON;
-
- menu.hIcon = LoadIconEx(I_CHKUPD);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMainMenuItem, (LPARAM)&menu);
- ReleaseIconEx(menu.hIcon);
-
- menu.hIcon = LoadIconEx(I_RSTRT);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMainMenuItemRestart, (LPARAM)&menu);
- ReleaseIconEx(menu.hIcon);
-
- menu.hIcon = LoadIconEx(I_CHKUPDEXT);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMainMenuItemUpdateAndExit, (LPARAM)&menu);
- ReleaseIconEx(menu.hIcon);
-
- return 0;
+ CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
}
+
void InitIcons(void)
{
SKINICONDESC sid = {0};
- char path[MAX_PATH];
+ TCHAR path[MAX_PATH];
int i;
sid.cbSize = sizeof(SKINICONDESC);
sid.pszSection = MODULE;
- sid.pszDefaultFile = path;
- GetModuleFileNameA(hInst, path, sizeof(path));
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.ptszDefaultFile = path;
+ GetModuleFileName(hInst, path, sizeof(path));
- for (i = 0; i < sizeof(iconList) / sizeof(IconStruct); ++i)
+ for (i = 0; i < SIZEOF(iconList); ++i)
{
sid.pszDescription = iconList[i].szDescr;
sid.pszName = iconList[i].szName;
sid.iDefaultIndex = -iconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIcolibIcon[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
}
-
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
-}
-
-
-void DeinitIcons(void)
-{
- if (hIcoLibIconsChanged) UnhookEvent(hIcoLibIconsChanged);
}
|