diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-19 22:48:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-19 22:48:01 +0000 |
commit | 95aa036670a1ce2c461ffd9bd3a586d191ee4675 (patch) | |
tree | cd244db18622df3462166ed39593ca924c890f6b /plugins/CountryFlags/src | |
parent | f6e0db0590e2f8feeacc29d4e50007fbe358f9d5 (diff) |
- various icolib fixes;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@1061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CountryFlags/src')
-rw-r--r-- | plugins/CountryFlags/src/icons.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp index 3b456a4d11..cde97ff74e 100644 --- a/plugins/CountryFlags/src/icons.cpp +++ b/plugins/CountryFlags/src/icons.cpp @@ -226,53 +226,51 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) void InitIcons(void)
{
- HIMAGELIST himl;
- SKINICONDESC sid;
char szId[20];
- int i,index;
- HICON hIcon;
WCHAR szName[64];
- LCID locale;
- locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
-
+ LCID locale = (LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
/* register icons */
- ZeroMemory(&sid,sizeof(sid));
- sid.cbSize=sizeof(sid);
- sid.pszName=szId;
- sid.cx=GetSystemMetrics(SM_CXSMICON);
- sid.cy=GetSystemMetrics(SM_CYSMICON);
- sid.flags=SIDF_SORTED|SIDF_TCHAR;
- sid.ptszSection=TranslateT("Country Flags");
+ SKINICONDESC sid = { 0 };
+ sid.cbSize = sizeof(sid);
+ sid.pszName = szId;
+ sid.cx = GetSystemMetrics(SM_CXSMICON);
+ sid.cy = GetSystemMetrics(SM_CYSMICON);
+ sid.flags = SIDF_SORTED | SIDF_TCHAR;
+ sid.ptszSection = TranslateT("Country Flags");
+
/* all those flag icons do not need any transparency mask (flags are always opaque),
* storing them in a large bitmap to reduce file size */
- himl=ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);
- if(himl!=NULL) {
- phIconHandles=(HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
- if(phIconHandles!=NULL)
- for(i=0;i<nCountriesCount;++i) {
-
+ HIMAGELIST himl = ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);
+ if (himl != NULL) {
+ phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
+ if (phIconHandles != NULL) {
+ for (int i=0; i < nCountriesCount; ++i) {
MultiByteToWideChar(locale,0,countries[i].szName,-1,szName,SIZEOF(szName));
- szName[SIZEOF(szName)-1]=L'\0';
- sid.pwszDescription=TranslateW(szName);
+ szName[SIZEOF(szName)-1] = L'\0';
+ sid.pwszDescription = TranslateW(szName);
/* create identifier */
- wsprintfA(szId,(countries[i].id==0xFFFF)?"%s0x%X":"%s%i","flags_",countries[i].id); /* buffer safe */
- index=CountryNumberToBitmapIndex(countries[i].id);
+ wsprintfA(szId,(countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i","flags_", countries[i].id); /* buffer safe */
+ int index = CountryNumberToBitmapIndex(countries[i].id);
/* create icon */
- hIcon=ImageList_GetIcon(himl,index,ILD_NORMAL);
- sid.hDefaultIcon=(hIcon!=NULL)?ResizeIconCentered(hIcon,sid.cx,sid.cy):NULL;
- if(hIcon!=NULL) DestroyIcon(hIcon);
- index=CountryNumberToIndex(countries[i].id);
+ HICON hIcon = ImageList_GetIcon(himl,index,ILD_NORMAL);
+ sid.hDefaultIcon = (hIcon != NULL) ? ResizeIconCentered(hIcon,sid.cx,sid.cy) : NULL;
+ if (hIcon != NULL)
+ DestroyIcon(hIcon);
+ index = CountryNumberToIndex(countries[i].id);
phIconHandles[index] = Skin_AddIcon(&sid);
- if(sid.hDefaultIcon!=NULL) DestroyIcon(sid.hDefaultIcon);
+ if (sid.hDefaultIcon != NULL)
+ DestroyIcon(sid.hDefaultIcon);
}
+ }
ImageList_Destroy(himl);
}
+
/* create services */
- hServiceLoadIcon=CreateServiceFunction(MS_FLAGS_LOADFLAGICON,ServiceLoadFlagIcon);
- hServiceCreateMergedIcon=CreateServiceFunction(MS_FLAGS_CREATEMERGEDFLAGICON,ServiceCreateMergedFlagIcon);
+ hServiceLoadIcon = CreateServiceFunction(MS_FLAGS_LOADFLAGICON, ServiceLoadFlagIcon);
+ hServiceCreateMergedIcon = CreateServiceFunction(MS_FLAGS_CREATEMERGEDFLAGICON, ServiceCreateMergedFlagIcon);
}
void UninitIcons(void)
|