From 854959cbc0a1bad2c086214be4d1a829b17a61f3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 1 Dec 2012 13:25:11 +0000 Subject: icolib: icon creation quirks git-svn-id: http://svn.miranda-ng.org/main/trunk@2588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp | 22 +++++++++++----------- plugins/UserInfoEx/src/classPsTreeItem.cpp | 11 ++++------- plugins/UserInfoEx/src/mir_icolib.cpp | 9 ++------- plugins/UserInfoEx/src/mir_icolib.h | 2 +- 4 files changed, 18 insertions(+), 26 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp index fe4ce708bb..f1b8232871 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp @@ -415,25 +415,25 @@ VOID InitIcons() phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE)); if (phIconHandles != NULL) { char szId[20]; - SKINICONDESC skid = { sizeof(skid) }; - skid.ptszSection = LPGENT("Country Flags"); - skid.pszName = szId; // name to refer to icon when playing and in db - skid.cx = GetSystemMetrics(SM_CXSMICON); - skid.cy = GetSystemMetrics(SM_CYSMICON); - skid.flags = SIDF_SORTED | SIDF_TCHAR; + SKINICONDESC sid = { sizeof(sid) }; + sid.ptszSection = LPGENT("Country Flags"); + sid.pszName = szId; // name to refer to icon when playing and in db + sid.cx = GetSystemMetrics(SM_CXSMICON); + sid.cy = GetSystemMetrics(SM_CYSMICON); + sid.flags = SIDF_SORTED | SIDF_TCHAR; for (int i=0; i < nCountriesCount; i++) { - skid.ptszDescription = mir_a2t(LPGEN(countries[i].szName)); + sid.ptszDescription = mir_a2t(LPGEN(countries[i].szName)); /* create identifier */ wsprintfA(szId,(countries[i].id==0xFFFF)?"%s0x%X":"%s%i","flags_",countries[i].id); /* buffer safe */ int index = CountryNumberToBitmapIndex(countries[i].id); /* create icon */ - skid.hDefaultIcon=ImageList_ExtractIcon(NULL, himl, index); + sid.hDefaultIcon = ImageList_ExtractIcon(NULL, himl, index); index = CountryNumberToIndex(countries[i].id); - phIconHandles[index] = Skin_AddIcon(&skid); - if(skid.hDefaultIcon!=NULL) DestroyIcon(skid.hDefaultIcon); - mir_free(skid.ptszDescription); skid.ptszDescription = NULL; + phIconHandles[index] = Skin_AddIcon(&sid); + if(sid.hDefaultIcon!=NULL) DestroyIcon(sid.hDefaultIcon); + mir_free(sid.ptszDescription); sid.ptszDescription = NULL; } } ImageList_Destroy(himl); diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index c9da4f453d..47d161e573 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -361,12 +361,8 @@ INT CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BOOLEAN bInitIcon LPCSTR pszIconName = IconKey(); // use icolib to handle icons - if (!(hIcon = IcoLib_GetIcon(pszIconName))) - { - SKINICONDESC sid; - - ZeroMemory(&sid, sizeof(sid)); - sid.cbSize = sizeof(sid); + if (!(hIcon = IcoLib_GetIcon(pszIconName))) { + SKINICONDESC sid = { sizeof(sid) }; sid.flags = SIDF_ALL_TCHAR; sid.cx = GetSystemMetrics(SM_CXSMICON); sid.cy = GetSystemMetrics(SM_CYSMICON); @@ -402,7 +398,8 @@ INT CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BOOLEAN bInitIcon else { sid.iDefaultIndex = -1; sid.hDefaultIcon = ProtoIcon(); - if (!sid.hDefaultIcon) sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL); + if (!sid.hDefaultIcon) + sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL); } // add file to icolib Skin_AddIcon(&sid); diff --git a/plugins/UserInfoEx/src/mir_icolib.cpp b/plugins/UserInfoEx/src/mir_icolib.cpp index ef5d22e487..adfa3e5149 100644 --- a/plugins/UserInfoEx/src/mir_icolib.cpp +++ b/plugins/UserInfoEx/src/mir_icolib.cpp @@ -380,19 +380,14 @@ HICON IcoLib_RegisterIcon(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, **/ VOID IcoLib_LoadModule() { - LPTSTR szDefaultFile; - INT_PTR i; - - // search for default icon file - szDefaultFile = IcoLib_GetDefaultIconFileName(); - + LPTSTR szDefaultFile = IcoLib_GetDefaultIconFileName(); IcoLib_CheckIconPackVersion(szDefaultFile); // load default icon if required ghDefIcon = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_DEFAULT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); - for (i = 0; i < SIZEOF(icoDesc); i++) { + for (int i = 0; i < SIZEOF(icoDesc); i++) { IcoLib_RegisterIconHandleEx( icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, szDefaultFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon); diff --git a/plugins/UserInfoEx/src/mir_icolib.h b/plugins/UserInfoEx/src/mir_icolib.h index d5ac62e9fa..e1743b18b1 100644 --- a/plugins/UserInfoEx/src/mir_icolib.h +++ b/plugins/UserInfoEx/src/mir_icolib.h @@ -138,7 +138,7 @@ typedef struct TIconCtrl LPTSTR IcoLib_GetDefaultIconFileName(); VOID IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls); -HANDLE IcoLib_RegisterIconHandle(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); +HANDLE IcoLib_RegisterIconHandle(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); HICON IcoLib_RegisterIcon(LPSTR szName, LPSTR szDescription, LPSTR szSection, INT idIcon, INT Size); HICON IcoLib_GetIcon(LPCSTR pszIcon); HICON IcoLib_GetIconByHandle(HANDLE hIconItem); -- cgit v1.2.3