From 8b4972feb7dc839d3a8537f9f1796a054c509d67 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 4 Aug 2022 20:47:49 +0300 Subject: UInfoEx to be compatible with custom icons --- plugins/ExternalAPI/m_userinfoex.h | 1 - plugins/UserInfoEx/src/classPsTreeItem.cpp | 19 +++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/ExternalAPI/m_userinfoex.h b/plugins/ExternalAPI/m_userinfoex.h index aa1de051ae..08b412b16e 100644 --- a/plugins/ExternalAPI/m_userinfoex.h +++ b/plugins/ExternalAPI/m_userinfoex.h @@ -34,7 +34,6 @@ Otherwise the default icon is displayed for this treeitem. #ifndef ODPF_UNICODE #define ODPF_UNICODE 8 // string fields in OPTIONSDIALOGPAGE are WCHAR* #endif -#define ODPF_ICON 64 // the hIcon member of the option dialog page is valid /* Handling notifications v0.1.0.4+ A dialogbox should call SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSP_CHANGED) on a PSN_INFOCHANGED notification if diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index d7971444cd..a44cfa820d 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -285,6 +285,7 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, bool bInitIconsOnly) // load the icon if no icolib is installed or creating the required settingname failed LPCSTR pszIconName = IconKey(); + HANDLE hIcoLib = nullptr; // use icolib to handle icons HICON hIcon = IcoLib_GetIcon(pszIconName); @@ -302,7 +303,6 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, bool bInitIconsOnly) if (uip->flags & ODPF_ICON) { // is it uinfoex item? if (uip->pPlugin == &g_plugin) { - // the pszGroup holds the iconfile for items added by uinfoex sid.defaultFile.w = uip->szGroup.w; @@ -316,11 +316,7 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, bool bInitIconsOnly) sid.iDefaultIndex = -1; } } - // default icon is delivered by the page to add - else { - sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL), bNeedFree = true; - sid.iDefaultIndex = -1; - } + else hIcoLib = (HANDLE)uip->dwInitParam; } // no icon to add, use default else { @@ -330,10 +326,11 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, bool bInitIconsOnly) sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL), bNeedFree = true; } // add file to icolib - g_plugin.addIcon(&sid); + if (!hIcoLib) + g_plugin.addIcon(&sid); if (!bInitIconsOnly) - hIcon = IcoLib_GetIcon(pszIconName); + hIcon = (hIcoLib) ? IcoLib_GetIconByHandle(hIcoLib) : IcoLib_GetIcon(pszIconName); if (bNeedFree) DestroyIcon(sid.hDefaultIcon); } @@ -343,8 +340,10 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, bool bInitIconsOnly) if (hIcon) return ((_iImage = ImageList_AddIcon(hIml, hIcon)) == -1); _iImage = 0; } - else - _iImage = -1; + else _iImage = -1; + + if (hIcoLib) + IcoLib_ReleaseIcon(hIcon); return 0; } -- cgit v1.2.3