diff options
author | George Hazan <ghazan@miranda.im> | 2019-04-13 00:11:59 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-04-13 00:11:59 +0300 |
commit | fee3a74e7429552ebbfe7ae9c14a4f6c25156fb6 (patch) | |
tree | e05460a85875a1c5f59b6244ac0e412095ac71b9 /src | |
parent | 48de7daae4384c86681f89255b63631cb832097c (diff) |
CMPluginBase::addImgListIcon: new helper to safely add an icolib icon to HIMAGELIST
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/CMPluginBase.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/clistmod.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/findadd.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/hotkey_opts.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/ignore.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/pluginopts.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/skinicons.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/visibility.cpp | 6 |
12 files changed, 44 insertions, 41 deletions
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index a18a3e15ff..3ced1cf459 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -279,6 +279,14 @@ void CMPluginBase::debugLogW(LPCWSTR wszFormat, ...) ///////////////////////////////////////////////////////////////////////////////////////// +int CMPluginBase::addImgListIcon(HIMAGELIST himl, int iconId) +{ + HICON hIcon = getIcon(iconId); + int ret = ::ImageList_AddIcon(himl, hIcon); + IcoLib_ReleaseIcon(hIcon); + return ret; +} + HICON CMPluginBase::getIcon(int iconId, bool big) { return IcoLib_GetIconByHandle(getIconHandle(iconId), big); diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index e56308f232..ed4c445e2a 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -135,7 +135,7 @@ MIR_APP_DLL(int) Clist_GetContactIcon(MCONTACT hContact) static void AddProtoIconIndex(PROTOACCOUNT *pa)
{
for (auto &it : g_statuses) {
- int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, it.iStatus);
+ int iImg = ImageList_AddProtoIcon(hCListImages, pa->szModuleName, it.iStatus);
if (it.iStatus == ID_STATUS_OFFLINE)
pa->iIconBase = iImg;
}
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index fdd69d0ef4..aca9b86624 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -390,7 +390,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetTextExtentPoint32(hdc, cbei.pszText, (int)mir_wstrlen(cbei.pszText), &textSize); if (textSize.cx > cbwidth) cbwidth = textSize.cx; - cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon_IconLibLoaded(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); + cbei.iImage = cbei.iSelectedImage = ImageList_AddSkinIcon(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); cbei.lParam = 0; SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CBEM_INSERTITEM, 0, (LPARAM)&cbei); cbei.iItem++; diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index ac1e2b23c4..58d07e1e5c 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -472,14 +472,14 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, Hotkey_Subclass(GetDlgItem(hwndDlg, IDC_HOTKEY)); { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 3, 1); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_MIRANDA); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOW); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ADDCONTACT); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_DELETE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNDO); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPOPEN); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPSHUT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_WINDOWS); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_MIRANDA); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_WINDOW); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_ADDCONTACT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_DELETE); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_UNDO); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPOPEN); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPSHUT); ListView_SetImageList(hwndHotkey, hIml, LVSIL_SMALL); } ListView_SetExtendedListViewStyle(hwndHotkey, LVS_EX_CHECKBOXES | LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP); diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 10ee55d64e..82a3772d17 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -208,14 +208,14 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM TranslateDialogDefault(hwndDlg);
{
HIMAGELIST hIml = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 3 + IGNOREEVENT_MAX, 3 + IGNOREEVENT_MAX);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_FILLEDBLOB);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_EMPTYBLOB);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_EVENT_MESSAGE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_EVENT_FILE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_USERONLINE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_AUTH_REQUEST);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_TYPING);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_FILLEDBLOB);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_EMPTYBLOB);
+ ImageList_AddSkinIcon(hIml, SKINICON_EVENT_MESSAGE);
+ ImageList_AddSkinIcon(hIml, SKINICON_EVENT_FILE);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_USERONLINE);
+ ImageList_AddSkinIcon(hIml, SKINICON_AUTH_REQUEST);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_TYPING);
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
for (int i = 0; i < _countof(hIcons); i++)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 8ff63cddf4..c04d269389 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -14,7 +14,7 @@ IcoLib_GetIconHandle @12 IcoLib_IsManaged @13
IcoLib_ReleaseIcon @14
Window_FreeIcon_IcoLib @15
-Window_SetSkinIcon_IcoLib @16
+Window_SetSkinIcon_IcoLib @16
Window_SetProtoIcon_IcoLib @17
ProtoServiceExists @18
mir_main @19
@@ -678,3 +678,6 @@ Srmm_SetIconFlags @767 ?getIcon@CMPluginBase@@QAEPAUHICON__@@H_N@Z @769 NONAME
?getIconHandle@CMPluginBase@@QAEPAXH@Z @770 NONAME
?releaseIcon@CMPluginBase@@QAEXH_N@Z @771 NONAME
+?addImgListIcon@CMPluginBase@@QAEHPAU_IMAGELIST@@H@Z @772 NONAME
+ImageList_AddProtoIcon @773
+ImageList_AddSkinIcon @774
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 8c725df9d3..06c417483d 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -14,7 +14,7 @@ IcoLib_GetIconHandle @12 IcoLib_IsManaged @13
IcoLib_ReleaseIcon @14
Window_FreeIcon_IcoLib @15
-Window_SetSkinIcon_IcoLib @16
+Window_SetSkinIcon_IcoLib @16
Window_SetProtoIcon_IcoLib @17
ProtoServiceExists @18
mir_main @19
@@ -678,3 +678,6 @@ Srmm_SetIconFlags @767 ?getIcon@CMPluginBase@@QEAAPEAUHICON__@@H_N@Z @769 NONAME
?getIconHandle@CMPluginBase@@QEAAPEAXH@Z @770 NONAME
?releaseIcon@CMPluginBase@@QEAAXH_N@Z @771 NONAME
+?addImgListIcon@CMPluginBase@@QEAAHPEAU_IMAGELIST@@H@Z @772 NONAME
+ImageList_AddProtoIcon @773
+ImageList_AddSkinIcon @774
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 0a737d81c7..cd25f39443 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -103,10 +103,7 @@ extern int g_iIconX, g_iIconY, g_iIconSX, g_iIconSY; HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared);
int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource);
-int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource);
-int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId);
-int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, int iconId);
int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon);
#define Safe_DestroyIcon(hIcon) if (hIcon) DestroyIcon(hIcon)
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 4164f19ecc..72014fb9b7 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -528,11 +528,11 @@ static bool loadClistModule(wchar_t *exe, pluginEntry *p) // now all core skin icons are loaded via icon lib. so lets release them
for (auto &it : g_statuses)
- ImageList_AddIcon_IconLibLoaded(hCListImages, it.iSkinIcon);
+ ImageList_AddSkinIcon(hCListImages, it.iSkinIcon);
// see IMAGE_GROUP... in clist.h if you add more images above here
- ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPOPEN);
- ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPSHUT);
+ ImageList_AddSkinIcon(hCListImages, SKINICON_OTHER_GROUPOPEN);
+ ImageList_AddSkinIcon(hCListImages, SKINICON_OTHER_GROUPSHUT);
if (p->load() == 0) {
p->bLoaded = true;
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index d7248a08b4..226fe9a9b2 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -290,8 +290,8 @@ public: bool OnInitDialog() override
{
HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_UNICODE);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_ANSI);
m_plugList.SetImageList(hIml, LVSIL_SMALL);
LVCOLUMN col;
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index 5c08661183..5c5c4b5a2b 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -159,7 +159,7 @@ int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource) return res;
}
-int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId)
+MIR_APP_DLL(int) ImageList_AddSkinIcon(HIMAGELIST hIml, int iconId)
{
HICON hIcon = Skin_LoadIcon(iconId);
int res = ImageList_AddIcon(hIml, hIcon);
@@ -167,7 +167,7 @@ int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId) return res;
}
-int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, int iconId)
+MIR_APP_DLL(int) ImageList_AddProtoIcon(HIMAGELIST hIml, const char *szProto, int iconId)
{
HICON hIcon = Skin_LoadProtoIcon(szProto, iconId);
int res = ImageList_AddIcon(hIml, hIcon);
@@ -175,14 +175,6 @@ int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, i return res;
}
-int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource)
-{
- HICON hTempIcon = LoadIconEx(hInstance, szResource, 0);
- int res = ImageList_ReplaceIcon(hIml, iIndex, hTempIcon);
- Safe_DestroyIcon(hTempIcon);
- return res;
-}
-
int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon)
{
int res = ImageList_ReplaceIcon(hIml, nIndex, hIcon);
diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp index e4bc479b61..f3a36df1de 100644 --- a/src/mir_app/src/visibility.cpp +++ b/src/mir_app/src/visibility.cpp @@ -139,9 +139,9 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP TranslateDialogDefault(hwndDlg);
hIml = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 3, 3);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_VISIBLE_ALL);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_INVISIBLE_ALL);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_VISIBLE_ALL);
+ ImageList_AddSkinIcon(hIml, SKINICON_OTHER_INVISIBLE_ALL);
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
hVisibleIcon = ImageList_GetIcon(hIml, 1, ILD_NORMAL);
SendDlgItemMessage(hwndDlg, IDC_VISIBLEICON, STM_SETICON, (WPARAM)hVisibleIcon, 0);
|