From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp | 4 +- plugins/Clist_modern/src/modern_cachefuncs.cpp | 20 +++--- plugins/Clist_modern/src/modern_clc.cpp | 40 +++++------ plugins/Clist_modern/src/modern_clcitems.cpp | 4 +- plugins/Clist_modern/src/modern_clcopts.cpp | 80 +++++++++++----------- plugins/Clist_modern/src/modern_clcpaint.cpp | 24 +++---- plugins/Clist_modern/src/modern_clcutils.cpp | 6 +- plugins/Clist_modern/src/modern_clistevents.cpp | 4 +- plugins/Clist_modern/src/modern_clistmenus.cpp | 12 ++-- plugins/Clist_modern/src/modern_clistmod.cpp | 2 +- plugins/Clist_modern/src/modern_clistopts.cpp | 6 +- plugins/Clist_modern/src/modern_clisttray.cpp | 2 +- plugins/Clist_modern/src/modern_clui.cpp | 26 +++---- plugins/Clist_modern/src/modern_contact.cpp | 4 +- plugins/Clist_modern/src/modern_log.cpp | 2 +- .../Clist_modern/src/modern_rowheight_funcs.cpp | 6 +- plugins/Clist_modern/src/modern_rowtemplateopt.cpp | 12 ++-- plugins/Clist_modern/src/modern_skinbutton.cpp | 6 +- plugins/Clist_modern/src/modern_skinengine.cpp | 24 +++---- plugins/Clist_modern/src/modern_skinopt.cpp | 40 +++++------ plugins/Clist_modern/src/modern_skinselector.cpp | 80 +++++++++++----------- plugins/Clist_modern/src/modern_statusbar.cpp | 12 ++-- .../Clist_modern/src/modern_statusbar_options.cpp | 22 +++--- plugins/Clist_modern/src/modern_sync.cpp | 2 +- plugins/Clist_modern/src/modern_tbbutton.cpp | 4 +- plugins/Clist_modern/src/modern_toolbar.cpp | 2 +- plugins/Clist_modern/src/modern_viewmodebar.cpp | 36 +++++----- 27 files changed, 241 insertions(+), 241 deletions(-) (limited to 'plugins/Clist_modern') diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp index b31d4e4a6c..6d854811f8 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp @@ -670,7 +670,7 @@ static int LocateStorePosition(int Frameid, int maxstored) char settingname[255]; for (int i = 0; i < maxstored; i++) { - mir_snprintf(settingname, SIZEOF(settingname), "Name%d", i); + mir_snprintf(settingname, _countof(settingname), "Name%d", i); DBVARIANT dbv = { 0 }; if (db_get_ts(NULL, CLUIFrameModule, settingname, &dbv)) continue; @@ -2902,7 +2902,7 @@ static LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam int oldflags; - mir_snprintf(TBcapt, SIZEOF(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", + mir_snprintf(TBcapt, _countof(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", g_pfwFrames[pos].szName, g_pfwFrames[pos].height, g_pfwFrames[pos].visible, g_pfwFrames[pos].floating, g_pfwFrames[pos].FloatingPos.x, g_pfwFrames[pos].FloatingPos.y, g_pfwFrames[pos].FloatingSize.x, g_pfwFrames[pos].FloatingSize.y, diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index f5128356ef..40dab74c2f 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -518,20 +518,20 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) if (dat->first_line_append_nick && (!dat->force_in_dialog)) { DBVARIANT dbv = { 0 }; if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) { - TCHAR nick[SIZEOF(contact->szText)]; - mir_tstrncpy(nick, dbv.ptszVal, SIZEOF(contact->szText)); + TCHAR nick[_countof(contact->szText)]; + mir_tstrncpy(nick, dbv.ptszVal, _countof(contact->szText)); db_free(&dbv); // They are the same -> use the name to keep the case if (mir_tstrcmpi(name, nick) == 0) - mir_tstrncpy(contact->szText, name, SIZEOF(contact->szText)); + mir_tstrncpy(contact->szText, name, _countof(contact->szText)); else // Append then - mir_sntprintf(contact->szText, SIZEOF(contact->szText), _T("%s - %s"), name, nick); + mir_sntprintf(contact->szText, _countof(contact->szText), _T("%s - %s"), name, nick); } - else mir_tstrncpy(contact->szText, name, SIZEOF(contact->szText)); + else mir_tstrncpy(contact->szText, name, _countof(contact->szText)); } - else mir_tstrncpy(contact->szText, name, SIZEOF(contact->szText)); + else mir_tstrncpy(contact->szText, name, _countof(contact->szText)); if (!dat->force_in_dialog) { SHORTDATA data = { 0 }; @@ -550,11 +550,11 @@ void Cache_GetSecondLineText(SHORTDATA *dat, ClcCacheEntry *pdnce) int type = TEXT_EMPTY; if (dat->second_line_show) - type = Cache_GetLineText(pdnce, dat->second_line_type, Text, SIZEOF(Text), dat->second_line_text, + type = Cache_GetLineText(pdnce, dat->second_line_type, Text, _countof(Text), dat->second_line_text, dat->second_line_xstatus_has_priority, dat->second_line_show_status_if_no_away, dat->second_line_show_listening_if_no_away, dat->second_line_use_name_and_message_for_xstatus, dat->contact_time_show_only_if_different); - Text[SIZEOF(Text) - 1] = 0; //to be sure that it is null terminated string + Text[_countof(Text) - 1] = 0; //to be sure that it is null terminated string replaceStrT(pdnce->szSecondLineText, (dat->second_line_show) ? Text : NULL); @@ -574,11 +574,11 @@ void Cache_GetThirdLineText(SHORTDATA *dat, ClcCacheEntry *pdnce) TCHAR Text[240 - EXTRA_ICON_COUNT] = { 0 }; int type = TEXT_EMPTY; if (dat->third_line_show) - type = Cache_GetLineText(pdnce, dat->third_line_type, Text, SIZEOF(Text), dat->third_line_text, + type = Cache_GetLineText(pdnce, dat->third_line_type, Text, _countof(Text), dat->third_line_text, dat->third_line_xstatus_has_priority, dat->third_line_show_status_if_no_away, dat->third_line_show_listening_if_no_away, dat->third_line_use_name_and_message_for_xstatus, dat->contact_time_show_only_if_different); - Text[SIZEOF(Text) - 1] = 0; //to be sure that it is null terminated string + Text[_countof(Text) - 1] = 0; //to be sure that it is null terminated string replaceStrT(pdnce->szThirdLineText, (dat->third_line_show) ? Text : NULL); if (pdnce->szThirdLineText) { diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index d5e740ecac..3618cf2d9b 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -62,7 +62,7 @@ static int clcExitDragToScroll(); int ReloadSkinFolder(WPARAM, LPARAM) { - FoldersGetCustomPathT(hSkinFolder, SkinsFolder, SIZEOF(SkinsFolder), _T(DEFAULT_SKIN_FOLDER)); + FoldersGetCustomPathT(hSkinFolder, SkinsFolder, _countof(SkinsFolder), _T(DEFAULT_SKIN_FOLDER)); return 0; } @@ -83,16 +83,16 @@ static int clcHookIconsChanged(WPARAM, LPARAM) { int i; if (MirandaExiting()) return 0; - for (i = 0; i < SIZEOF(g_pAvatarOverlayIcons); i++) { + for (i = 0; i < _countof(g_pAvatarOverlayIcons); i++) { g_pAvatarOverlayIcons[i].listID = -1; g_pStatusOverlayIcons[i].listID = -1; } if (hAvatarOverlays) ImageList_Destroy(hAvatarOverlays); - hAvatarOverlays = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, SIZEOF(g_pAvatarOverlayIcons) * 2, 1); + hAvatarOverlays = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, _countof(g_pAvatarOverlayIcons) * 2, 1); - for (i = 0; i < SIZEOF(g_pAvatarOverlayIcons); i++) { + for (i = 0; i < _countof(g_pAvatarOverlayIcons); i++) { HICON hIcon = IcoLib_GetIcon(g_pAvatarOverlayIcons[i].name); g_pAvatarOverlayIcons[i].listID = ImageList_AddIcon(hAvatarOverlays, hIcon); IcoLib_Release(g_pAvatarOverlayIcons[i].name); @@ -1145,7 +1145,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (mir_strcmp(contSour->proto, META_PROTO)) { if (!contSour->isSubcontact) { MCONTACT hDest = contDest->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText); int res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { MCONTACT handle = CallService(MS_MC_CONVERTTOMETA, hDest, 0); @@ -1158,7 +1158,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, else { hcontact = contSour->hContact; MCONTACT hdest = contDest->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it (remove it from '%s')?"), contDest->szText, contSour->szText, contSour->subcontacts->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it (remove it from '%s')?"), contDest->szText, contSour->szText, contSour->subcontacts->szText); int res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact (moving)"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { MCONTACT handle = (MCONTACT)CallService(MS_MC_CONVERTTOMETA, (WPARAM)hdest, 0); @@ -1184,7 +1184,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (!contSour->isSubcontact) { MCONTACT hcontact = contSour->hContact; MCONTACT handle = contDest->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->szText); int res = MessageBox(hwnd, Wording, TranslateT("Adding contact to metacontact"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { if (!handle) @@ -1194,7 +1194,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, } else if (contSour->subcontacts == contDest) { MCONTACT hsour = contSour->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be default?"), contSour->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be default?"), contSour->szText); int res = MessageBox(hwnd, Wording, TranslateT("Set default contact"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) db_mc_setDefault(contDest->hContact, hsour, true); @@ -1202,7 +1202,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, else { MCONTACT hcontact = contSour->hContact; MCONTACT handle = contDest->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->szText); int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { if (!handle) @@ -1226,7 +1226,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (!contSour->isSubcontact) { MCONTACT hcontact = contSour->hContact; MCONTACT handle = contDest->subcontacts->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->subcontacts->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->subcontacts->szText); int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { if (!handle) @@ -1238,7 +1238,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, else if (contSour->subcontacts != contDest->subcontacts) { MCONTACT hcontact = contSour->hContact; MCONTACT handle = contDest->subcontacts->hContact; - mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->subcontacts->szText); + mir_sntprintf(Wording, _countof(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->subcontacts->szText); int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION); if (res == 1) { if (!handle) @@ -1276,9 +1276,9 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (shortGroup) { NeedRename = TRUE; if (sourceGrName) - mir_sntprintf(newName, SIZEOF(newName), _T("%s\\%s"), sourceGrName, shortGroup); + mir_sntprintf(newName, _countof(newName), _T("%s\\%s"), sourceGrName, shortGroup); else - mir_tstrncpy(newName, shortGroup, SIZEOF(newName)); + mir_tstrncpy(newName, shortGroup, _countof(newName)); } mir_free(groupName); mir_free(sourceGrName); @@ -1507,7 +1507,7 @@ static LRESULT clcOnIntmNameChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP return ret; if (contact) { - mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText)); + mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); Cache_GetText(dat, contact, 1); cliRecalcScrollBar(hwnd, dat); } @@ -1631,11 +1631,11 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); hSkinFolder = FoldersRegisterCustomPathT(LPGEN("Skins"), LPGEN("Modern contact list"), MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER)); - FoldersGetCustomPathT(hSkinFolder, SkinsFolder, SIZEOF(SkinsFolder), _T(DEFAULT_SKIN_FOLDER)); + FoldersGetCustomPathT(hSkinFolder, SkinsFolder, _countof(SkinsFolder), _T(DEFAULT_SKIN_FOLDER)); // Get icons TCHAR szMyPath[MAX_PATH]; - GetModuleFileName(g_hInst, szMyPath, SIZEOF(szMyPath)); + GetModuleFileName(g_hInst, szMyPath, _countof(szMyPath)); SKINICONDESC sid = { 0 }; sid.cx = sid.cy = 16; @@ -1649,7 +1649,7 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) IcoLib_AddIcon(&sid); sid.section.a = LPGEN("Contact list") "/" LPGEN("Avatar overlay"); - for (int i = 0; i < SIZEOF(g_pAvatarOverlayIcons); i++) { + for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) { sid.description.a = g_pAvatarOverlayIcons[i].description; sid.pszName = g_pAvatarOverlayIcons[i].name; sid.iDefaultIndex = -g_pAvatarOverlayIcons[i].id; @@ -1657,7 +1657,7 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) } sid.section.a = LPGEN("Contact list") "/" LPGEN("Status overlay"); - for (int i = 0; i < SIZEOF(g_pStatusOverlayIcons); i++) { + for (int i = 0; i < _countof(g_pStatusOverlayIcons); i++) { sid.description.a = g_pStatusOverlayIcons[i].description; sid.pszName = g_pStatusOverlayIcons[i].name; sid.iDefaultIndex = -g_pStatusOverlayIcons[i].id; @@ -1781,7 +1781,7 @@ int ClcGetShortData(ClcData* pData, SHORTDATA *pShortData) pShortData->second_line_draw_smileys = pData->second_line_draw_smileys; pShortData->second_line_type = pData->second_line_type; - mir_tstrncpy(pShortData->second_line_text, pData->second_line_text, SIZEOF(pShortData->second_line_text)); + mir_tstrncpy(pShortData->second_line_text, pData->second_line_text, _countof(pShortData->second_line_text)); pShortData->second_line_xstatus_has_priority = pData->second_line_xstatus_has_priority; pShortData->second_line_show_status_if_no_away = pData->second_line_show_status_if_no_away; @@ -1793,7 +1793,7 @@ int ClcGetShortData(ClcData* pData, SHORTDATA *pShortData) pShortData->third_line_draw_smileys = pData->third_line_draw_smileys; pShortData->third_line_type = pData->third_line_type; - mir_tstrncpy(pShortData->third_line_text, pData->third_line_text, SIZEOF(pShortData->third_line_text)); + mir_tstrncpy(pShortData->third_line_text, pData->third_line_text, _countof(pShortData->third_line_text)); pShortData->third_line_xstatus_has_priority = pData->third_line_xstatus_has_priority; pShortData->third_line_show_status_if_no_away = pData->third_line_show_status_if_no_away; diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index eb3442289b..4ebc0806bd 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -248,7 +248,7 @@ void* AddTempGroup(HWND hwnd, ClcData *dat, const TCHAR *szName) _itoa_s(i - 1, buf, 10); TCHAR b2[255]; - mir_sntprintf(b2, SIZEOF(b2), _T("#%s"), szName); + mir_sntprintf(b2, _countof(b2), _T("#%s"), szName); b2[0] = 1 | GROUPF_EXPANDED; db_set_ws(NULL, "CListGroups", buf, b2); pcli->pfnGetGroupName(i, &groupFlags); @@ -717,7 +717,7 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, Clc } if (g_CluiData.bFilterEffective & CLVM_FILTER_GROUPS) { if (!db_get_ts(hContact, "CList", "Group", &dbv)) { - mir_sntprintf(szGroupMask, SIZEOF(szGroupMask), _T("%s|"), &dbv.ptszVal[0]); + mir_sntprintf(szGroupMask, _countof(szGroupMask), _T("%s|"), &dbv.ptszVal[0]); filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | (_tcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0)) : (filterResult & (_tcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0)); mir_free(dbv.ptszVal); } diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index aaf414c3ad..6c2a3b15f6 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -135,33 +135,33 @@ void RegisterCLUIFonts(void) int index = 0; fontid.cbSize = sizeof(fontid); - mir_strncpy(fontid.dbSettingsGroup, "CLC", SIZEOF(fontid.dbSettingsGroup)); + mir_strncpy(fontid.dbSettingsGroup, "CLC", _countof(fontid.dbSettingsGroup)); effectid.cbSize = sizeof(effectid); - mir_strncpy(effectid.dbSettingsGroup, "CLC", SIZEOF(effectid.dbSettingsGroup)); + mir_strncpy(effectid.dbSettingsGroup, "CLC", _countof(effectid.dbSettingsGroup)); - for (int i = 0; i < SIZEOF(fontOptionsList); i++, index++) { + for (int i = 0; i < _countof(fontOptionsList); i++, index++) { fontid.flags = FIDF_DEFAULTVALID | FIDF_APPENDNAME | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_ALLOWREREGISTER | FIDF_NOAS; fontid.flags |= fontOptionsList[i].dwFlags; - mir_tstrncpy(fontid.group, fontOptionsList[i].szGroup, SIZEOF(fontid.group)); - mir_tstrncpy(fontid.name, fontOptionsList[i].szDescr, SIZEOF(fontid.name)); + mir_tstrncpy(fontid.group, fontOptionsList[i].szGroup, _countof(fontid.group)); + mir_tstrncpy(fontid.name, fontOptionsList[i].szDescr, _countof(fontid.name)); mir_snprintf(idstr, "Font%d", fontOptionsList[i].fontID); - mir_strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix)); + mir_strncpy(fontid.prefix, idstr, _countof(fontid.prefix)); fontid.order = i + 1; fontid.deffontsettings.charset = fontOptionsList[i].defCharset; fontid.deffontsettings.colour = fontOptionsList[i].defColour; fontid.deffontsettings.size = fontOptionsList[i].defSize; fontid.deffontsettings.style = fontOptionsList[i].defStyle; - mir_tstrncpy(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, SIZEOF(fontid.deffontsettings.szFace)); + mir_tstrncpy(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, _countof(fontid.deffontsettings.szFace)); FontRegisterT(&fontid); - mir_tstrncpy(effectid.group, fontOptionsList[i].szGroup, SIZEOF(effectid.group)); - mir_tstrncpy(effectid.name, fontOptionsList[i].szDescr, SIZEOF(effectid.name)); + mir_tstrncpy(effectid.group, fontOptionsList[i].szGroup, _countof(effectid.group)); + mir_tstrncpy(effectid.name, fontOptionsList[i].szDescr, _countof(effectid.name)); mir_snprintf(idstr, "Font%d", fontOptionsList[i].fontID); - mir_strncpy(effectid.setting, idstr, SIZEOF(effectid.setting)); + mir_strncpy(effectid.setting, idstr, _countof(effectid.setting)); effectid.order = i + 1; effectid.defeffect.effectIndex = fontOptionsList[i].defeffect.effectIndex; @@ -174,11 +174,11 @@ void RegisterCLUIFonts(void) ColourIDT colourid = { 0 }; colourid.cbSize = sizeof(colourid); - for (int i = 0; i < SIZEOF(colourOptionsList); i++) { - mir_tstrncpy(colourid.group, colourOptionsList[i].szGroup, SIZEOF(colourid.group)); - mir_tstrncpy(colourid.name, colourOptionsList[i].szDescr, SIZEOF(colourid.group)); - mir_strncpy(colourid.setting, colourOptionsList[i].chName, SIZEOF(colourid.setting)); - mir_strncpy(colourid.dbSettingsGroup, colourOptionsList[i].chGroup, SIZEOF(colourid.dbSettingsGroup)); + for (int i = 0; i < _countof(colourOptionsList); i++) { + mir_tstrncpy(colourid.group, colourOptionsList[i].szGroup, _countof(colourid.group)); + mir_tstrncpy(colourid.name, colourOptionsList[i].szDescr, _countof(colourid.group)); + mir_strncpy(colourid.setting, colourOptionsList[i].chName, _countof(colourid.setting)); + mir_strncpy(colourid.dbSettingsGroup, colourOptionsList[i].chGroup, _countof(colourid.dbSettingsGroup)); colourid.defcolour = colourOptionsList[i].defColour; colourid.order = i + 1; ColourRegisterT(&colourid); @@ -202,17 +202,17 @@ void GetFontSetting(int i, LOGFONT *lf, COLORREF *colour, BYTE *effect, COLORREF char idstr[32]; int index; - for (index = 0; index < SIZEOF(fontOptionsList); index++) + for (index = 0; index < _countof(fontOptionsList); index++) if (fontOptionsList[index].fontID == i) break; - if (index == SIZEOF(fontOptionsList)) + if (index == _countof(fontOptionsList)) return; FontIDT fontid = { 0 }; fontid.cbSize = sizeof(fontid); - mir_tstrncpy(fontid.group, fontOptionsList[index].szGroup, SIZEOF(fontid.group)); - mir_tstrncpy(fontid.name, fontOptionsList[index].szDescr, SIZEOF(fontid.name)); + mir_tstrncpy(fontid.group, fontOptionsList[index].szGroup, _countof(fontid.group)); + mir_tstrncpy(fontid.name, fontOptionsList[index].szDescr, _countof(fontid.name)); COLORREF col = CallService(MS_FONT_GETT, (WPARAM)&fontid, (LPARAM)lf); @@ -389,12 +389,12 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); { DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", GetDefaultExStyle()); - for (int i = 0; i < SIZEOF(checkBoxToStyleEx); i++) + for (int i = 0; i < _countof(checkBoxToStyleEx); i++) CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id, (exStyle&checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag*checkBoxToStyleEx[i].neg) ? BST_CHECKED : BST_UNCHECKED); UDACCEL accel[2] = { { 0, 10 }, { 2, 50 } }; SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETRANGE, 0, MAKELONG(999, 0)); - SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, SIZEOF(accel), (LPARAM)&accel); + SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, _countof(accel), (LPARAM)&accel); SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME), 0)); } CheckDlgButton(hwndDlg, IDC_IDLE, db_get_b(NULL, "CLC", "ShowIdle", CLCDEFAULT_SHOWIDLE) ? BST_CHECKED : BST_UNCHECKED); @@ -405,8 +405,8 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_SMOOTHTIME), IsDlgButtonChecked(hwndDlg, IDC_NOTNOSMOOTHSCROLLING)); EnableWindow(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), IsDlgButtonChecked(hwndDlg, IDC_GREYOUT)); - FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, SIZEOF(greyoutValues), db_get_dw(NULL, "CLC", "FullGreyoutFlags", CLCDEFAULT_FULLGREYOUTFLAGS)); - FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, SIZEOF(offlineValues), db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES)); + FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, _countof(greyoutValues), db_get_dw(NULL, "CLC", "FullGreyoutFlags", CLCDEFAULT_FULLGREYOUTFLAGS)); + FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, _countof(offlineValues), db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES)); CheckDlgButton(hwndDlg, IDC_NOSCROLLBAR, db_get_b(NULL, "CLC", "NoVScrollBar", CLCDEFAULT_NOVSCROLL) ? BST_CHECKED : BST_UNCHECKED); return TRUE; @@ -449,7 +449,7 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: DWORD exStyle = 0; - for (int i = 0; i < SIZEOF(checkBoxToStyleEx); i++) + for (int i = 0; i < _countof(checkBoxToStyleEx); i++) if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].neg) exStyle |= checkBoxToStyleEx[i].flag; db_set_dw(NULL, "CLC", "ExStyle", exStyle); @@ -512,7 +512,7 @@ static INT_PTR CALLBACK DlgProcClistOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { int i, item; int s1, s2, s3; - for (i = 0; i < SIZEOF(sortby); i++) { + for (i = 0; i < _countof(sortby); i++) { item = SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_ADDSTRING, 0, (LPARAM)TranslateTS(sortby[i])); SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETITEMDATA, item, 0); item = SendDlgItemMessage(hwndDlg, IDC_CLSORT2, CB_ADDSTRING, 0, (LPARAM)TranslateTS(sortby[i])); @@ -525,7 +525,7 @@ static INT_PTR CALLBACK DlgProcClistOpts(HWND hwndDlg, UINT msg, WPARAM wParam, s2 = db_get_b(NULL, "CList", "SortBy2", SETTING_SORTBY2_DEFAULT); s3 = db_get_b(NULL, "CList", "SortBy3", SETTING_SORTBY3_DEFAULT); - for (i = 0; i < SIZEOF(sortby); i++) { + for (i = 0; i < _countof(sortby); i++) { if (s1 == sortbyValue[i]) SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETCURSEL, i, 0); if (s2 == sortbyValue[i]) @@ -804,7 +804,7 @@ static INT_PTR CALLBACK DlgProcClistBehaviourOpts(HWND hwndDlg, UINT msg, WPARAM EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC01), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); { TCHAR *hidemode[] = { TranslateT("Hide to tray"), TranslateT("Behind left edge"), TranslateT("Behind right edge") }; - for (int i = 0; i < SIZEOF(hidemode); i++) { + for (int i = 0; i < _countof(hidemode); i++) { int item = SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_ADDSTRING, 0, (LPARAM)hidemode[i]); SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_SETITEMDATA, item, 0); SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_SETCURSEL, db_get_b(NULL, "ModernData", "HideBehind", SETTING_HIDEBEHIND_DEFAULT), 0); @@ -1013,7 +1013,7 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP SendDlgItemMessage(hwndDlg, IDC_TITLETEXT, CB_ADDSTRING, 0, (LPARAM)MIRANDANAME); char szUin[20]; - mir_snprintf(szUin, SIZEOF(szUin), "%u", db_get_dw(NULL, "ICQ", "UIN", 0)); + mir_snprintf(szUin, _countof(szUin), "%u", db_get_dw(NULL, "ICQ", "UIN", 0)); SendDlgItemMessage(hwndDlg, IDC_TITLETEXT, CB_ADDSTRING, 0, (LPARAM)szUin); if (!db_get_s(NULL, "ICQ", "Nick", &dbv)) { @@ -1149,7 +1149,7 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP db_set_b(NULL, "CList", "NoBorder", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOBORDERWND)); { TCHAR title[256]; - GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, SIZEOF(title)); + GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, _countof(title)); db_set_ws(NULL, "CList", "TitleText", title); } db_set_b(NULL, "CList", "Min2Tray", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY)); @@ -1276,7 +1276,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (!db_get_s(NULL, module, "BkBitmap", &dbv)) { int retval = PathToAbsolute(dbv.pszVal, dat->item[indx].filename); if (!retval || retval == CALLSERVICE_NOTFOUND) - mir_strncpy(dat->item[indx].filename, dbv.pszVal, SIZEOF(dat->item[indx].filename)); + mir_strncpy(dat->item[indx].filename, dbv.pszVal, _countof(dat->item[indx].filename)); mir_free(dbv.pszVal); } else *dat->item[indx].filename = 0; @@ -1311,7 +1311,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, dat->item[indx].bkColor = SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0); dat->item[indx].selColor = SendDlgItemMessage(hwndDlg, IDC_SELCOLOUR, CPM_GETCOLOUR, 0, 0); - GetDlgItemTextA(hwndDlg, IDC_FILENAME, dat->item[indx].filename, SIZEOF(dat->item[indx].filename)); + GetDlgItemTextA(hwndDlg, IDC_FILENAME, dat->item[indx].filename, _countof(dat->item[indx].filename)); WORD flags = 0; if (IsDlgButtonChecked(hwndDlg, IDC_STRETCHH)) flags |= CLB_STRETCHH; @@ -1361,7 +1361,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case M_BKGR_UPDATE: { int isChecked = IsDlgButtonChecked(hwndDlg, IDC_BITMAP); - for (int indx = 0; indx < SIZEOF(bitmapRelatedControls); indx++) + for (int indx = 0; indx < _countof(bitmapRelatedControls); indx++) EnableWindow(GetDlgItem(hwndDlg, bitmapRelatedControls[indx]), isChecked); } break; @@ -1369,8 +1369,8 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_COMMAND: if (LOWORD(wParam) == IDC_BROWSE) { TCHAR str[MAX_PATH], filter[512]; - Bitmap_GetFilter(filter, SIZEOF(filter)); - GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str)); + Bitmap_GetFilter(filter, _countof(filter)); + GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str)); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; @@ -1378,7 +1378,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.nMaxFile = SIZEOF(str); + ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = _T("bmp"); if (!GetOpenFileName(&ofn)) @@ -1642,7 +1642,7 @@ static INT_PTR CALLBACK DlgProcModernOptions(HWND hwndDlg, UINT msg, WPARAM wPar bInit = true; { int i, item; - for (i = 0; i < SIZEOF(opts); ++i) + for (i = 0; i < _countof(opts); ++i) OptCheckBox_Load(hwndDlg, opts + i); EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIME), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); @@ -1664,7 +1664,7 @@ static INT_PTR CALLBACK DlgProcModernOptions(HWND hwndDlg, UINT msg, WPARAM wPar SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_SETPOS, TRUE, db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT)); SendMessage(hwndDlg, WM_HSCROLL, 0x12345678, 0); - for (i = 0; i < SIZEOF(sortby); i++) { + for (i = 0; i < _countof(sortby); i++) { item = SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_ADDSTRING, 0, (LPARAM)TranslateTS(sortby[i])); SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETITEMDATA, item, 0); item = SendDlgItemMessage(hwndDlg, IDC_CLSORT2, CB_ADDSTRING, 0, (LPARAM)TranslateTS(sortby[i])); @@ -1677,7 +1677,7 @@ static INT_PTR CALLBACK DlgProcModernOptions(HWND hwndDlg, UINT msg, WPARAM wPar int s2 = db_get_b(NULL, "CList", "SortBy2", SETTING_SORTBY2_DEFAULT); int s3 = db_get_b(NULL, "CList", "SortBy3", SETTING_SORTBY3_DEFAULT); - for (i = 0; i < SIZEOF(sortby); i++) { + for (i = 0; i < _countof(sortby); i++) { if (s1 == sortbyValue[i]) SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETCURSEL, i, 0); if (s2 == sortbyValue[i]) @@ -1730,7 +1730,7 @@ static INT_PTR CALLBACK DlgProcModernOptions(HWND hwndDlg, UINT msg, WPARAM wPar case PSN_APPLY: g_mutex_bChangingMode = TRUE; - for (int i = 0; i < SIZEOF(opts); ++i) + for (int i = 0; i < _countof(opts); ++i) OptCheckBox_Save(hwndDlg, opts + i); SetWindowPos(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); @@ -1826,7 +1826,7 @@ int ClcOptInit(WPARAM wParam, LPARAM) odp.pfnDlgProc = DlgProcClistListOpts; odp.flags = ODPF_BOLDGROUPS; - for (int i = 0; i < SIZEOF(clist_opt_items); i++) { + for (int i = 0; i < _countof(clist_opt_items); i++) { odp.pszTemplate = MAKEINTRESOURCEA(clist_opt_items[i].id); odp.pszTab = clist_opt_items[i].name; odp.pfnDlgProc = clist_opt_items[i].wnd_proc; diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index a621838d29..f8c845ac65 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -1108,7 +1108,7 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact TCHAR buf[70] = _T(""); mir_free_and_nil(pdnce->szSecondLineText); - TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); pdnce->szSecondLineText = mir_tstrdup(buf); } @@ -1136,7 +1136,7 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact TCHAR buf[70] = _T(""); mir_free(pdnce->szThirdLineText); - TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); pdnce->szThirdLineText = mir_tstrdup(buf); } @@ -1289,7 +1289,7 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact //TODO fix overlays // Draw overlay if (dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + (dat->avatars_draw_border ? 2 : 0) - && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < SIZEOF(g_pAvatarOverlayIcons)) { + && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < _countof(g_pAvatarOverlayIcons)) { p_rect.top = p_rect.bottom - ICON_HEIGHT; p_rect.left = p_rect.right - ICON_HEIGHT; @@ -1417,7 +1417,7 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact case TC_TIME: TCHAR szResult[80]; - if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { + if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) { // Select font ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL); ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), &p_rect, DT_NOPREFIX | DT_SINGLELINE | (dat->text_rtl ? DT_RTLREADING : 0)); @@ -2015,7 +2015,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT text_left_pos = row_rc.right; // Now let's check what we have to draw for (item_iterator = 0; item_iterator < NUM_ITEM_TYPE && free_row_rc.left < free_row_rc.right; item_iterator++) { - if (Drawing->ext_nItemsNum >= SIZEOF(Drawing->ext_mpItemsDesc)) break; + if (Drawing->ext_nItemsNum >= _countof(Drawing->ext_mpItemsDesc)) break; if (left) item = item_iterator; else @@ -2130,7 +2130,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT && (!Drawing->image_is_special || !has_avatar || (dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + (dat->avatars_draw_border ? 2 : 0) - && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < SIZEOF(g_pAvatarOverlayIcons) + && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < _countof(g_pAvatarOverlayIcons) && dat->avatars_overlay_type == SETTING_AVATAR_OVERLAY_TYPE_CONTACT))) { // Don't have to draw and don't have to keep the empty space break; @@ -2163,7 +2163,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT if (Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) { TCHAR szResult[80]; - if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { + if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) { SIZE text_size; RECT rc; @@ -2351,7 +2351,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT if (dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); - TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); mir_free(pdnce->szSecondLineText); pdnce->szSecondLineText = mir_tstrdup(buf); } @@ -2385,7 +2385,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT if (dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); - TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); mir_free(pdnce->szThirdLineText); pdnce->szThirdLineText = mir_tstrdup(buf); } @@ -2612,7 +2612,7 @@ void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, int overlayIdx = -1; int blendmode = 255; if (dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + (dat->avatars_draw_border ? 2 : 0) - && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < SIZEOF(g_pAvatarOverlayIcons)) { + && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < _countof(g_pAvatarOverlayIcons)) { switch (dat->avatars_overlay_type) { case SETTING_AVATAR_OVERLAY_TYPE_NORMAL: overlayIdx = g_pAvatarOverlayIcons[GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE].listID; @@ -2676,7 +2676,7 @@ void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, DeleteObject(rgn); // Draw overlays if (dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + (dat->avatars_draw_border ? 2 : 0) - && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < SIZEOF(g_pAvatarOverlayIcons)) { + && GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE < _countof(g_pAvatarOverlayIcons)) { POINT ptOverlay = { prcItem->right - ICON_HEIGHT, prcItem->bottom - ICON_HEIGHT }; if (dat->avatars_draw_border) { ptOverlay.x--; @@ -2818,7 +2818,7 @@ void CLCPaint::_DrawContactTime(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R if (!pdnce) return; - if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { + if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) { // Select font ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL); ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), prcItem, DT_NOPREFIX | DT_SINGLELINE); diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index c98a8645b5..9d16e85de7 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -531,7 +531,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) else { int defItems[] = { ITEM_ICON, ITEM_TEXT, ITEM_EXTRA_ICONS, }; for (int i = 0; i < NUM_ITEM_TYPE; i++) - dat->row_items[i] = (i < SIZEOF(defItems)) ? defItems[i] : -1; + dat->row_items[i] = (i < _countof(defItems)) ? defItems[i] : -1; } // Avatar @@ -611,7 +611,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) ptrT tszLineText(db_get_tsa(NULL, "CList", "SecondLineText")); if (tszLineText) - mir_tstrncpy(dat->second_line_text, tszLineText, SIZEOF(dat->second_line_text)); + mir_tstrncpy(dat->second_line_text, tszLineText, _countof(dat->second_line_text)); else dat->second_line_text[0] = _T('\0'); @@ -639,7 +639,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) ptrT tszLineText(db_get_tsa(NULL, "CList", "ThirdLineText")); if (tszLineText) - mir_tstrncpy(dat->third_line_text, tszLineText, SIZEOF(dat->third_line_text)); + mir_tstrncpy(dat->third_line_text, tszLineText, _countof(dat->third_line_text)); else dat->third_line_text[0] = _T('\0'); diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index 6ef62cc6ee..cabc2363da 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -108,8 +108,8 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle) MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_DATA | MIIM_BITMAP | MIIM_ID; if (p->cle.pszService && - (!strncmp("SRMsg/ReadMessage", p->cle.pszService, SIZEOF("SRMsg/ReadMessage")) || - !strncmp("GChat/DblClickEvent", p->cle.pszService, SIZEOF("GChat/DblClickEvent")))) + (!strncmp("SRMsg/ReadMessage", p->cle.pszService, _countof("SRMsg/ReadMessage")) || + !strncmp("GChat/DblClickEvent", p->cle.pszService, _countof("GChat/DblClickEvent")))) { // dup check only for msg events for (int j = 0; j < GetMenuItemCount(g_CluiData.hMenuNotify); j++) { diff --git a/plugins/Clist_modern/src/modern_clistmenus.cpp b/plugins/Clist_modern/src/modern_clistmenus.cpp index 3f9bf7bc7c..41dce30d7c 100644 --- a/plugins/Clist_modern/src/modern_clistmenus.cpp +++ b/plugins/Clist_modern/src/modern_clistmenus.cpp @@ -94,8 +94,8 @@ static IconItem iconList[] = static int FAV_OnContactMenuBuild(WPARAM hContact, LPARAM) { BYTE bContactRate = db_get_b(hContact, "CList", "Rate", 0); - if (bContactRate > SIZEOF(rates) - 1) - bContactRate = SIZEOF(rates) - 1; + if (bContactRate > _countof(rates) - 1) + bContactRate = _countof(rates) - 1; BOOL bModifyMenu = FALSE; @@ -130,12 +130,12 @@ static int FAV_OnContactMenuBuild(WPARAM hContact, LPARAM) mi.hParentMenu = hFavoriteContactMenu; if (!hFavoriteContactMenuItems) { - hFavoriteContactMenuItems = (HGENMENU *)malloc(sizeof(HANDLE) * SIZEOF(rates)); - memset(hFavoriteContactMenuItems, 0, sizeof(HANDLE) * SIZEOF(rates)); + hFavoriteContactMenuItems = (HGENMENU *)malloc(sizeof(HANDLE) * _countof(rates)); + memset(hFavoriteContactMenuItems, 0, sizeof(HANDLE) * _countof(rates)); } int i; - for (i = 0; i < SIZEOF(rates); i++) { + for (i = 0; i < _countof(rates); i++) { mi.icolibItem = iconList[i].hIcolib; mi.ptszName = rates[i]; mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR | ((bContactRate == i) ? CMIF_CHECKED : 0); @@ -181,7 +181,7 @@ INT_PTR FAV_ToggleShowOffline(WPARAM hContact, LPARAM) int LoadFavoriteContactMenu() { - Icon_Register(g_hInst, LPGEN("Contact list"), iconList, SIZEOF(iconList)); + Icon_Register(g_hInst, LPGEN("Contact list"), iconList, _countof(iconList)); CreateServiceFunction(CLUI_FAVSETRATE, FAV_SetRate); CreateServiceFunction(CLUI_FAVTOGGLESHOWOFFLINE, FAV_ToggleShowOffline); diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index 7015a99388..f4489c499d 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -299,7 +299,7 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) hAux = GetAncestor(hAux, GA_ROOTOWNER); if (hAuxOld == hAux) { TCHAR buf[255]; - GetClassName(hAux, buf, SIZEOF(buf)); + GetClassName(hAux, buf, _countof(buf)); if (!mir_tstrcmp(buf, CLUIFrameSubContainerClassName)) { hWndFound = TRUE; break; diff --git a/plugins/Clist_modern/src/modern_clistopts.cpp b/plugins/Clist_modern/src/modern_clistopts.cpp index 20e6f19089..4173bb0751 100644 --- a/plugins/Clist_modern/src/modern_clistopts.cpp +++ b/plugins/Clist_modern/src/modern_clistopts.cpp @@ -720,7 +720,7 @@ static INT_PTR CALLBACK DlgProcItemSecondLineOpts(HWND hwndDlg, UINT msg, WPARAM db_set_w(NULL, "CList", "SecondLineType", (WORD)radio); TCHAR t[TEXT_TEXT_MAX_LENGTH]; - GetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, t, SIZEOF(t)); + GetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, t, _countof(t)); t[TEXT_TEXT_MAX_LENGTH - 1] = '\0'; db_set_ts(NULL, "CList", "SecondLineText", t); @@ -887,7 +887,7 @@ static INT_PTR CALLBACK DlgProcItemThirdLineOpts(HWND hwndDlg, UINT msg, WPARAM { TCHAR t[TEXT_TEXT_MAX_LENGTH]; - GetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, t, SIZEOF(t)); + GetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, t, _countof(t)); t[TEXT_TEXT_MAX_LENGTH - 1] = '\0'; db_set_ws(NULL, "CList", "ThirdLineText", t); @@ -940,7 +940,7 @@ int CListOptInit(WPARAM wParam, LPARAM) odp.pszTitle = LPGEN("Row items"); odp.flags = ODPF_BOLDGROUPS; - for (int i = 0; i < SIZEOF(row_opt_items); i++) { + for (int i = 0; i < _countof(row_opt_items); i++) { odp.pszTemplate = MAKEINTRESOURCEA(row_opt_items[i].id); odp.pszTab = row_opt_items[i].name; odp.pfnDlgProc = row_opt_items[i].wnd_proc; diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index a0430c6172..a90a5e69aa 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -649,7 +649,7 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int) // if Tipper is missing or turned off for tray, use system tooltips if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(NULL, "Tipper", "TrayTip", 1)) - mir_tstrncpy(nid.szTip, pcli->szTip, SIZEOF(nid.szTip)); + mir_tstrncpy(nid.szTip, pcli->szTip, _countof(nid.szTip)); Shell_NotifyIcon(NIM_MODIFY, &nid); diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 8c663dfcd0..bc79b2372a 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -191,7 +191,7 @@ int CLUI::OnEvent_ContactMenuPreBuild(WPARAM, LPARAM) HWND hwndClist = GetFocus(); TCHAR cls[128]; - GetClassName(hwndClist, cls, SIZEOF(cls)); + GetClassName(hwndClist, cls, _countof(cls)); if (mir_tstrcmp(_T(CLISTCONTROL_CLASS), cls)) hwndClist = pcli->hwndContactList; @@ -334,7 +334,7 @@ static IconItemT iconItem[] = { HRESULT CLUI::RegisterAvatarMenu() { - Icon_RegisterT(g_hInst, LPGENT("Contact list"), iconItem, SIZEOF(iconItem)); + Icon_RegisterT(g_hInst, LPGENT("Contact list"), iconItem, _countof(iconItem)); CLISTMENUITEM mi = { sizeof(mi) }; CreateServiceFunction("CList/ShowContactAvatar", CLUI::Service_Menu_ShowContactAvatar); @@ -487,7 +487,7 @@ HICON GetMainStatusOverlay(int STATUS) void UnloadAvatarOverlayIcon() { - for (int i = 0; i < SIZEOF(g_pAvatarOverlayIcons); i++) { + for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) { g_pAvatarOverlayIcons[i].listID = -1; g_pStatusOverlayIcons[i].listID = -1; } @@ -679,9 +679,9 @@ void CLUI_ChangeWindowMode() TCHAR titleText[255] = { 0 }; DBVARIANT dbv; if (db_get_ts(NULL, "CList", "TitleText", &dbv)) - mir_tstrncpy(titleText, _T(MIRANDANAME), SIZEOF(titleText)); + mir_tstrncpy(titleText, _T(MIRANDANAME), _countof(titleText)); else { - mir_tstrncpy(titleText, dbv.ptszVal, SIZEOF(titleText)); + mir_tstrncpy(titleText, dbv.ptszVal, _countof(titleText)); db_free(&dbv); } SetWindowText(pcli->hwndContactList, titleText); @@ -905,7 +905,7 @@ static int CLUI_GetConnectingIconForProtoCount(char *szAccoName) if (szAccoName) { // first of all try to find by account name( or empty - global ) - mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, szAccoName); + mir_sntprintf(fileFull, _countof(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, szAccoName); if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1)) return count; @@ -913,7 +913,7 @@ static int CLUI_GetConnectingIconForProtoCount(char *szAccoName) // second try to find by protocol name PROTOACCOUNT *acc = Proto_GetAccount(szAccoName); if (acc && !acc->bOldProto) { - mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, acc->szProtoName); + mir_sntprintf(fileFull, _countof(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, acc->szProtoName); if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1)) return count; } @@ -921,7 +921,7 @@ static int CLUI_GetConnectingIconForProtoCount(char *szAccoName) } // third try global - mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn.dll"), tszFolderPath); + mir_sntprintf(fileFull, _countof(fileFull), _T("%s\\Icons\\proto_conn.dll"), tszFolderPath); if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1)) return count; @@ -947,7 +947,7 @@ static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx) HICON hIcon; if (szAccoName) { - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("proto_conn_%S.dll"), szAccoName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("proto_conn_%S.dll"), szAccoName); if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx)) return hIcon; @@ -955,7 +955,7 @@ static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx) // second try to find by protocol name PROTOACCOUNT *acc = Proto_GetAccount(szAccoName); if (acc && !acc->bOldProto) { - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("proto_conn_%S.dll"), acc->szProtoName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("proto_conn_%S.dll"), acc->szProtoName); if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx)) return hIcon; } @@ -963,7 +963,7 @@ static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx) } // third try global - mir_tstrncpy(szFullPath, _T("proto_conn.dll"), SIZEOF(szFullPath)); + mir_tstrncpy(szFullPath, _T("proto_conn.dll"), _countof(szFullPath)); if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx)) return hIcon; @@ -1562,7 +1562,7 @@ HANDLE RegisterIcolibIconHandle(char *szIcoID, char *szSectionName, char *szDesc if (fileFull[0] != _T('\0')) sid.iDefaultIndex = -iDefaultIndex; else { - GetModuleFileName(hDefaultModuleInst, fileFull, SIZEOF(fileFull)); + GetModuleFileName(hDefaultModuleInst, fileFull, _countof(fileFull)); sid.iDefaultIndex = -iDefaultResource; } @@ -1592,7 +1592,7 @@ LRESULT CLUI::PreProcessWndProc(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bH if (msg == uMsgGetProfile && wParam != 0) { // got IPC message int rc = 0; char szName[MAX_PATH]; - mir_snprintf(szName, SIZEOF(szName), "Miranda::%u", wParam); // caller will tell us the ID of the map + mir_snprintf(szName, _countof(szName), "Miranda::%u", wParam); // caller will tell us the ID of the map HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, szName); if (hMap != NULL) { void *hView = NULL; diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 272daa123c..bfc6aab7fd 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -57,7 +57,7 @@ void cli_ChangeContactIcon(MCONTACT hContact, int iIcon, int add) static int GetStatusModeOrdering(int statusMode) { - for (int i = 0; i < SIZEOF(statusModeOrder); i++) + for (int i = 0; i < _countof(statusModeOrder); i++) if (statusModeOrder[i].status == statusMode) return statusModeOrder[i].order; return 1000; @@ -153,7 +153,7 @@ int CompareContacts2(const ClcContact *contact1, const ClcContact *contact2, int int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) { int i, r; - for (i = 0; i < SIZEOF(g_CluiData.bSortByOrder); i++) + for (i = 0; i < _countof(g_CluiData.bSortByOrder); i++) { r = CompareContacts2(contact1, contact2, g_CluiData.bSortByOrder[i]); if (r != 0) diff --git a/plugins/Clist_modern/src/modern_log.cpp b/plugins/Clist_modern/src/modern_log.cpp index f14ec4ca36..780177c2a1 100644 --- a/plugins/Clist_modern/src/modern_log.cpp +++ b/plugins/Clist_modern/src/modern_log.cpp @@ -21,7 +21,7 @@ void Log(const char *file, int line, const char *fmt, ...) file_tmp++; va_start(vararg, fmt); - mir_vsnprintf(str, SIZEOF(str), fmt, vararg); + mir_vsnprintf(str, _countof(str), fmt, vararg); va_end(vararg); { char * tmp = str; diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index 5766aa8e08..aa07ffd865 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -288,7 +288,7 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i if (item == -1) { TCHAR szResult[80]; - if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { + if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) { SIZE text_size = { 0 }; RECT rc = { 0 }; // Select font @@ -397,7 +397,7 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd) if (!dat->text_ignore_size_for_row_height) { // Get contact font size tmp = 0; - for (i = 0; i < SIZEOF(contact_fonts); i++) + for (i = 0; i < _countof(contact_fonts); i++) if (tmp < dat->fontModernInfo[contact_fonts[i]].fontHeight) tmp = dat->fontModernInfo[contact_fonts[i]].fontHeight; @@ -421,7 +421,7 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd) } // Get other font sizes - for (i = 0; i < SIZEOF(other_fonts); i++) + for (i = 0; i < _countof(other_fonts); i++) if (max_height < dat->fontModernInfo[other_fonts[i]].fontHeight) max_height = dat->fontModernInfo[other_fonts[i]].fontHeight; } diff --git a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp index 92630786c4..fa5ec60d54 100644 --- a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp +++ b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp @@ -317,16 +317,16 @@ void RefreshTree(HWND hwndDlg, HTREEITEM hti) if (cell->type == 0) mir_sntprintf(buf, TranslateT("Empty %s cell"), cell->cont == TC_COL ? TranslateT("column") : TranslateT("line")); else - mir_tstrncpy(buf, TranslateTS(types[cell->type]), SIZEOF(buf)); + mir_tstrncpy(buf, TranslateTS(types[cell->type]), _countof(buf)); } else { if (cell->type == 0) - mir_tstrncpy(buf, (cell->cont != TC_COL ? TranslateT("columns") : TranslateT("lines")), SIZEOF(buf)); + mir_tstrncpy(buf, (cell->cont != TC_COL ? TranslateT("columns") : TranslateT("lines")), _countof(buf)); else mir_sntprintf(buf, TranslateT("%s, contain %s"), TranslateTS(types[cell->type]), cell->cont != TC_COL ? TranslateT("columns") : TranslateT("lines")); } - if (cell->layer) mir_tstrncat(buf, TranslateT(" layered"), SIZEOF(buf) - mir_tstrlen(buf)); + if (cell->layer) mir_tstrncat(buf, TranslateT(" layered"), _countof(buf) - mir_tstrlen(buf)); tvi.mask = TVIF_HANDLE | TVIF_TEXT; tvi.pszText = buf; TreeView_SetItem(htree, &tvi); @@ -359,21 +359,21 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM int i, item; - for (i = 0; i < SIZEOF(types); i++) { + for (i = 0; i < _countof(types); i++) { item = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(types[i])); SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETITEMDATA, item, 0); } SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETCURSEL, 0, 0); TCHAR *h_alignment[] = { _T("left"), _T("hCenter"), _T("right") }; - for (i = 0; i < SIZEOF(h_alignment); i++) { + for (i = 0; i < _countof(h_alignment); i++) { item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(h_alignment[i])); SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETITEMDATA, item, 0); } SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETCURSEL, 0, 0); TCHAR *v_alignment[] = { _T("top"), _T("vCenter"), _T("bottom") }; - for (i = 0; i < SIZEOF(v_alignment); i++) { + for (i = 0; i < _countof(v_alignment); i++) { item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(v_alignment[i])); SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETITEMDATA, item, 0); } diff --git a/plugins/Clist_modern/src/modern_skinbutton.cpp b/plugins/Clist_modern/src/modern_skinbutton.cpp index 2e2d8ec652..4e78f1c789 100644 --- a/plugins/Clist_modern/src/modern_skinbutton.cpp +++ b/plugins/Clist_modern/src/modern_skinbutton.cpp @@ -142,15 +142,15 @@ static int ModernSkinButtonPaintWorker(HWND hwnd, HDC whdc) } case 'd': defval = db_get_dw(NULL, section, key, defval); - Value = mir_strdup(_ltoa(defval, buf, SIZEOF(buf))); + Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; case 'w': defval = db_get_w(NULL, section, key, defval); - Value = mir_strdup(_ltoa(defval, buf, SIZEOF(buf))); + Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; case 'b': defval = db_get_b(NULL, section, key, defval); - Value = mir_strdup(_ltoa(defval, buf, SIZEOF(buf))); + Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; } mir_free(section); diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 551a079f6b..5e71a539dd 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -215,12 +215,12 @@ int IniParser::GetSkinFolder(IN const TCHAR * szFileName, OUT TCHAR * pszFolderN TCHAR custom_folder[MAX_PATH], cus[MAX_PATH]; TCHAR *b3; - mir_tstrncpy(custom_folder, pszFolderName, SIZEOF(custom_folder)); + mir_tstrncpy(custom_folder, pszFolderName, _countof(custom_folder)); b3 = custom_folder + mir_tstrlen(custom_folder); while (b3 > custom_folder && *b3 != _T('\\')) { b3--; } *b3 = _T('\0'); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("SkinFolder"), _T(""), cus, SIZEOF(custom_folder), szFileName); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("SkinFolder"), _T(""), cus, _countof(custom_folder), szFileName); if (cus[0] != 0) mir_sntprintf(pszFolderName, MAX_PATH, _T("%s\\%s"), custom_folder, cus); @@ -266,7 +266,7 @@ HRESULT IniParser::_DoParseFile() { char szLine[MAX_LINE_LEN]; _nLine = 0; - while (fgets(szLine, SIZEOF(szLine), _hFile) != NULL) { + while (fgets(szLine, _countof(szLine), _hFile) != NULL) { size_t len = 0; char * pLine = (char*)_RemoveTailings(szLine, len); if (len > 0) { @@ -1483,9 +1483,9 @@ int ske_GetFullFilename(TCHAR *buf, const TCHAR *file, TCHAR *skinfolder, BOOL m TCHAR b2[MAX_PATH]; if (file[0] != '\\' && file[1] != ':') - mir_sntprintf(b2, SIZEOF(b2), _T("%s\\%s"), (skinfolder == NULL) ? SkinPlace : ((INT_PTR)skinfolder != -1) ? skinfolder : _T(""), file); + mir_sntprintf(b2, _countof(b2), _T("%s\\%s"), (skinfolder == NULL) ? SkinPlace : ((INT_PTR)skinfolder != -1) ? skinfolder : _T(""), file); else - mir_tstrncpy(b2, file, SIZEOF(b2)); + mir_tstrncpy(b2, file, _countof(b2)); if (madeAbsolute) { if (b2[0] == '\\' && b2[1] != '\\') @@ -2983,13 +2983,13 @@ static int ske_ValidateSingleFrameImage(FRAMEWND * Frame, BOOL SkipBkgBlitting) BitBlt(g_pCachedWindow->hImageDC, rLine.left, rLine.top, rLine.right - rLine.left, rLine.bottom - rLine.top, g_pCachedWindow->hBackDC, rLine.left, rLine.top, SRCCOPY); char req[255]; - mir_snprintf(req, SIZEOF(req), "Main,ID=ScrollBar,Frame=%s,Part=Back", Frame->szName); + mir_snprintf(req, _countof(req), "Main,ID=ScrollBar,Frame=%s,Part=Back", Frame->szName); SkinDrawGlyph(g_pCachedWindow->hImageDC, &rLine, &rLine, req); - mir_snprintf(req, SIZEOF(req), "Main,ID=ScrollBar,Frame=%s,Part=Thumb", Frame->szName); + mir_snprintf(req, _countof(req), "Main,ID=ScrollBar,Frame=%s,Part=Thumb", Frame->szName); SkinDrawGlyph(g_pCachedWindow->hImageDC, &rThumb, &rThumb, req); - mir_snprintf(req, SIZEOF(req), "Main,ID=ScrollBar, Frame=%s,Part=UpLineButton", Frame->szName); + mir_snprintf(req, _countof(req), "Main,ID=ScrollBar, Frame=%s,Part=UpLineButton", Frame->szName); SkinDrawGlyph(g_pCachedWindow->hImageDC, &rUpBtn, &rUpBtn, req); - mir_snprintf(req, SIZEOF(req), "Main,ID=ScrollBar,Frame=%s,Part=DownLineButton", Frame->szName); + mir_snprintf(req, _countof(req), "Main,ID=ScrollBar,Frame=%s,Part=DownLineButton", Frame->szName); SkinDrawGlyph(g_pCachedWindow->hImageDC, &rDnBtn, &rDnBtn, req); } @@ -3302,9 +3302,9 @@ static DWORD ske_HexToARGB(char * Hex) char buf2[11] = { 0 }; mir_snprintf(buf, "%s\n", Hex); if (buf[1] == 'x' || buf[1] == 'X') - mir_snprintf(buf2, SIZEOF(buf2), "0x%s\n", buf + 2); + mir_snprintf(buf2, _countof(buf2), "0x%s\n", buf + 2); else - mir_snprintf(buf2, SIZEOF(buf2), "0x%s\n", buf); + mir_snprintf(buf2, _countof(buf2), "0x%s\n", buf); buf2[10] = '\0'; char *st; @@ -3450,7 +3450,7 @@ static void ske_AddParseSkinFont(char * szFontID, char * szDefineString) logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; char buf[255]; - mir_strncpy(logfont.lfFaceName, GetParamN(szDefineString, buf, sizeof(buf), 0, ',', TRUE), SIZEOF(logfont.lfFaceName)); + mir_strncpy(logfont.lfFaceName, GetParamN(szDefineString, buf, sizeof(buf), 0, ',', TRUE), _countof(logfont.lfFaceName)); logfont.lfHeight = atoi(GetParamN(szDefineString, buf, sizeof(buf), 1, ',', TRUE)); if (logfont.lfHeight < 0) { HDC hdc = CreateCompatibleDC(NULL); diff --git a/plugins/Clist_modern/src/modern_skinopt.cpp b/plugins/Clist_modern/src/modern_skinopt.cpp index 7fa5958ebb..d55aed2cd7 100644 --- a/plugins/Clist_modern/src/modern_skinopt.cpp +++ b/plugins/Clist_modern/src/modern_skinopt.cpp @@ -119,10 +119,10 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara } if (!sd) return 0; if (sd->File && !_tcschr(sd->File, _T('%'))) { - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Author"), TranslateT("( unknown )"), Author, SIZEOF(Author), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("URL"), _T(""), URL, SIZEOF(URL), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Contact"), _T(""), Contact, SIZEOF(Contact), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Description"), _T(""), Description, SIZEOF(Description), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Author"), TranslateT("( unknown )"), Author, _countof(Author), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("URL"), _T(""), URL, _countof(URL), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Contact"), _T(""), Contact, _countof(Contact), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Description"), _T(""), Description, _countof(Description), sd->File); mir_sntprintf(text, TranslateT("%s\n\n%s\n\nAuthor(s):\t %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s"), sd->Name, Description, Author, Contact, URL, sd->File); } @@ -250,9 +250,9 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara SetDlgItemText(hwndDlg, IDC_EDIT_SKIN_FILENAME, buf); TCHAR prfn[MAX_PATH] = { 0 }, imfn[MAX_PATH] = { 0 }, skinfolder[MAX_PATH] = { 0 }; - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, SIZEOF(imfn), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, _countof(imfn), sd->File); IniParser::GetSkinFolder(sd->File, skinfolder); - mir_sntprintf(prfn, SIZEOF(prfn), _T("%s\\%s"), skinfolder, imfn); + mir_sntprintf(prfn, _countof(prfn), _T("%s\\%s"), skinfolder, imfn); PathToAbsoluteT(prfn, imfn); hPreviewBitmap = ske_LoadGlyphImage(imfn); @@ -275,10 +275,10 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (!sd) return 0; if (sd->File && !_tcschr(sd->File, _T('%'))) { - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Author"), TranslateT("( unknown )"), Author, SIZEOF(Author), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("URL"), _T(""), URL, SIZEOF(URL), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Contact"), _T(""), Contact, SIZEOF(Contact), sd->File); - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Description"), _T(""), Description, SIZEOF(Description), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Author"), TranslateT("( unknown )"), Author, _countof(Author), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("URL"), _T(""), URL, _countof(URL), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Contact"), _T(""), Contact, _countof(Contact), sd->File); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Description"), _T(""), Description, _countof(Description), sd->File); mir_sntprintf(text, TranslateT("Preview is not available\n\n%s\n----------------------\n\n%s\n\nAUTHOR(S):\n%s\n\nCONTACT:\n%s\n\nHOMEPAGE:\n%s"), sd->Name, Description, Author, Contact, URL); } @@ -332,7 +332,7 @@ int SearchSkinFiles(HWND hwndDlg, TCHAR * Folder) struct _tfinddata_t fd = { 0 }; TCHAR mask[MAX_PATH]; long hFile; - mir_sntprintf(mask, SIZEOF(mask), _T("%s\\*.msf"), Folder); + mir_sntprintf(mask, _countof(mask), _T("%s\\*.msf"), Folder); //fd.attrib = _A_SUBDIR; hFile = _tfindfirst(mask, &fd); if (hFile != -1) @@ -342,14 +342,14 @@ int SearchSkinFiles(HWND hwndDlg, TCHAR * Folder) } while (!_tfindnext(hFile, &fd)); _findclose(hFile); } - mir_sntprintf(mask, SIZEOF(mask), _T("%s\\*"), Folder); + mir_sntprintf(mask, _countof(mask), _T("%s\\*"), Folder); hFile = _tfindfirst(mask, &fd); { do { if (fd.attrib&_A_SUBDIR && !(mir_tstrcmpi(fd.name, _T(".")) == 0 || mir_tstrcmpi(fd.name, _T("..")) == 0)) {//Next level of subfolders TCHAR path[MAX_PATH]; - mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), Folder, fd.name); + mir_sntprintf(path, _countof(path), _T("%s\\%s"), Folder, fd.name); SearchSkinFiles(hwndDlg, path); } } while (!_tfindnext(hFile, &fd)); @@ -384,7 +384,7 @@ HTREEITEM AddSkinToListFullName(HWND hwndDlg, TCHAR * fullName) TCHAR path[MAX_PATH] = { 0 }; TCHAR file[MAX_PATH] = { 0 }; TCHAR *buf; - mir_tstrncpy(path, fullName, SIZEOF(path)); + mir_tstrncpy(path, fullName, _countof(path)); buf = path + mir_tstrlen(path); while (buf > path) { @@ -396,7 +396,7 @@ HTREEITEM AddSkinToListFullName(HWND hwndDlg, TCHAR * fullName) buf--; } buf++; - mir_tstrncpy(file, buf, SIZEOF(file)); + mir_tstrncpy(file, buf, _countof(file)); return AddSkinToList(hwndDlg, path, file); } @@ -414,10 +414,10 @@ HTREEITEM AddSkinToList(HWND hwndDlg, TCHAR * path, TCHAR* file) _tcsncpy_s(fullName, TranslateT("Default Skin"), _TRUNCATE); } else { - mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s"), path, file); + mir_sntprintf(fullName, _countof(fullName), _T("%s\\%s"), path, file); _tcsncpy_s(defskinname, file, _TRUNCATE); TCHAR *p = _tcsrchr(defskinname, '.'); if (p) *p = 0; - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Name"), defskinname, sd->Name, SIZEOF(sd->Name), fullName); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Name"), defskinname, sd->Name, _countof(sd->Name), fullName); _tcsncpy_s(sd->File, fullName, _TRUNCATE); } return AddItemToTree(GetDlgItem(hwndDlg, IDC_TREE1), sd->Name, sd); @@ -437,7 +437,7 @@ HTREEITEM FindChild(HWND hTree, HTREEITEM Parent, TCHAR * Caption, void * data) tvi.hItem = tmp; tvi.mask = TVIF_TEXT | TVIF_HANDLE; tvi.pszText = buf; - tvi.cchTextMax = SIZEOF(buf); + tvi.cchTextMax = _countof(buf); TreeView_GetItem(hTree, &tvi); if (mir_tstrcmpi(Caption, tvi.pszText) == 0) { if (!data) @@ -520,9 +520,9 @@ INT_PTR SvcPreviewSkin(WPARAM wParam, LPARAM lParam) TCHAR prfn[MAX_PATH] = { 0 }; TCHAR imfn[MAX_PATH] = { 0 }; TCHAR skinfolder[MAX_PATH] = { 0 }; - GetPrivateProfileString(_T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, SIZEOF(imfn), (LPCTSTR)lParam); + GetPrivateProfileString(_T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, _countof(imfn), (LPCTSTR)lParam); IniParser::GetSkinFolder((LPCTSTR)lParam, skinfolder); - mir_sntprintf(prfn, SIZEOF(prfn), _T("%s\\%s"), skinfolder, imfn); + mir_sntprintf(prfn, _countof(prfn), _T("%s\\%s"), skinfolder, imfn); PathToAbsoluteT(prfn, imfn); hPreviewBitmap = ske_LoadGlyphImage(imfn); diff --git a/plugins/Clist_modern/src/modern_skinselector.cpp b/plugins/Clist_modern/src/modern_skinselector.cpp index 3563b12c7b..64c9aad075 100644 --- a/plugins/Clist_modern/src/modern_skinselector.cpp +++ b/plugins/Clist_modern/src/modern_skinselector.cpp @@ -502,7 +502,7 @@ int RegisterButtonByParce(char * ObjectName, char * Params) { char buf[255]; int res; - GetParamN(Params, buf, SIZEOF(buf), 0, ',', 0); + GetParamN(Params, buf, _countof(buf), 0, ',', 0); // if (boolstrcmpi("Push",buf) { //Push type char buf2[20] = { 0 }; @@ -518,20 +518,20 @@ int RegisterButtonByParce(char * ObjectName, char * Params) DWORD alingnto; int a = ((int)!mir_strcmpi(buf, "Switch")) * 2; - GetParamN(Params, pServiceName, SIZEOF(pServiceName), 1, ',', 0); + GetParamN(Params, pServiceName, _countof(pServiceName), 1, ',', 0); // if (a) GetParamN(Params,pStatusServiceName, sizeof(pStatusServiceName),a+1,',',0); - Left = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 2, ',', 0)); - Top = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 3, ',', 0)); - Right = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 4, ',', 0)); - Bottom = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 5, ',', 0)); - GetParamN(Params, TL, SIZEOF(TL), a + 6, ',', 0); - - MinWidth = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 7, ',', 0)); - MinHeight = atoi(GetParamN(Params, buf2, SIZEOF(buf2), a + 8, ',', 0)); - GetParamNT(Params, Hint, SIZEOF(Hint), a + 9, ',', 0); + Left = atoi(GetParamN(Params, buf2, _countof(buf2), a + 2, ',', 0)); + Top = atoi(GetParamN(Params, buf2, _countof(buf2), a + 3, ',', 0)); + Right = atoi(GetParamN(Params, buf2, _countof(buf2), a + 4, ',', 0)); + Bottom = atoi(GetParamN(Params, buf2, _countof(buf2), a + 5, ',', 0)); + GetParamN(Params, TL, _countof(TL), a + 6, ',', 0); + + MinWidth = atoi(GetParamN(Params, buf2, _countof(buf2), a + 7, ',', 0)); + MinHeight = atoi(GetParamN(Params, buf2, _countof(buf2), a + 8, ',', 0)); + GetParamNT(Params, Hint, _countof(Hint), a + 9, ',', 0); if (a) { - GetParamN(Params, Section, SIZEOF(Section), 2, ',', 0); - GetParamN(Params, Type, SIZEOF(Type), 3, ',', 0); + GetParamN(Params, Section, _countof(Section), 2, ',', 0); + GetParamN(Params, Type, _countof(Type), 3, ',', 0); } alingnto = ((TL[0] == 'R') ? SBF_ALIGN_TL_RIGHT : 0) + ((TL[0] == 'C') ? SBF_ALIGN_TL_HCENTER : 0) @@ -560,7 +560,7 @@ int RegisterObjectByParce(char * ObjectName, char * Params) SKINOBJECTDESCRIPTOR obj = { 0 }; char buf[250]; obj.szObjectID = mir_strdup(ObjectName); - GetParamN(Params, buf, SIZEOF(buf), 0, ',', 0); + GetParamN(Params, buf, _countof(buf), 0, ',', 0); if (!mir_strcmpi(buf, "Glyph")) obj.bType = OT_GLYPHOBJECT; else if (!mir_strcmpi(buf, "Font")) @@ -570,26 +570,26 @@ int RegisterObjectByParce(char * ObjectName, char * Params) case OT_GLYPHOBJECT: { GLYPHOBJECT gl = { 0 }; - GetParamN(Params, buf, SIZEOF(buf), 1, ',', 0); + GetParamN(Params, buf, _countof(buf), 1, ',', 0); if (!mir_strcmpi(buf, "Solid")) { // Solid gl.Style = ST_BRUSH; - int r = atoi(GetParamN(Params, buf, SIZEOF(buf), 2, ',', 0)); - int g = atoi(GetParamN(Params, buf, SIZEOF(buf), 3, ',', 0)); - int b = atoi(GetParamN(Params, buf, SIZEOF(buf), 4, ',', 0)); - gl.dwAlpha = atoi(GetParamN(Params, buf, SIZEOF(buf), 5, ',', 0)); + int r = atoi(GetParamN(Params, buf, _countof(buf), 2, ',', 0)); + int g = atoi(GetParamN(Params, buf, _countof(buf), 3, ',', 0)); + int b = atoi(GetParamN(Params, buf, _countof(buf), 4, ',', 0)); + gl.dwAlpha = atoi(GetParamN(Params, buf, _countof(buf), 5, ',', 0)); gl.dwColor = RGB(r, g, b); } else if (!mir_strcmpi(buf, "Image")) { // Image gl.Style = ST_IMAGE; - gl.szFileName = mir_strdup(GetParamN(Params, buf, SIZEOF(buf), 2, ',', 0)); - gl.dwLeft = atoi(GetParamN(Params, buf, SIZEOF(buf), 4, ',', 0)); - gl.dwTop = atoi(GetParamN(Params, buf, SIZEOF(buf), 5, ',', 0)); - gl.dwRight = atoi(GetParamN(Params, buf, SIZEOF(buf), 6, ',', 0)); - gl.dwBottom = atoi(GetParamN(Params, buf, SIZEOF(buf), 7, ',', 0)); - gl.dwAlpha = atoi(GetParamN(Params, buf, SIZEOF(buf), 8, ',', 0)); - GetParamN(Params, buf, SIZEOF(buf), 3, ',', 0); + gl.szFileName = mir_strdup(GetParamN(Params, buf, _countof(buf), 2, ',', 0)); + gl.dwLeft = atoi(GetParamN(Params, buf, _countof(buf), 4, ',', 0)); + gl.dwTop = atoi(GetParamN(Params, buf, _countof(buf), 5, ',', 0)); + gl.dwRight = atoi(GetParamN(Params, buf, _countof(buf), 6, ',', 0)); + gl.dwBottom = atoi(GetParamN(Params, buf, _countof(buf), 7, ',', 0)); + gl.dwAlpha = atoi(GetParamN(Params, buf, _countof(buf), 8, ',', 0)); + GetParamN(Params, buf, _countof(buf), 3, ',', 0); if (!mir_strcmpi(buf, "TileBoth")) gl.FitMode = FM_TILE_BOTH; else if (!mir_strcmpi(buf, "TileVert")) gl.FitMode = FM_TILE_VERT; else if (!mir_strcmpi(buf, "TileHorz")) gl.FitMode = FM_TILE_HORZ; @@ -598,19 +598,19 @@ int RegisterObjectByParce(char * ObjectName, char * Params) else if (!mir_strcmpi(buf, "Fragment")) { //Image gl.Style = ST_FRAGMENT; - gl.szFileName = mir_strdup(GetParamN(Params, buf, SIZEOF(buf), 2, ',', 0)); - - gl.clipArea.x = atoi(GetParamN(Params, buf, SIZEOF(buf), 3, ',', 0)); - gl.clipArea.y = atoi(GetParamN(Params, buf, SIZEOF(buf), 4, ',', 0)); - gl.szclipArea.cx = atoi(GetParamN(Params, buf, SIZEOF(buf), 5, ',', 0)); - gl.szclipArea.cy = atoi(GetParamN(Params, buf, SIZEOF(buf), 6, ',', 0)); - - gl.dwLeft = atoi(GetParamN(Params, buf, SIZEOF(buf), 8, ',', 0)); - gl.dwTop = atoi(GetParamN(Params, buf, SIZEOF(buf), 9, ',', 0)); - gl.dwRight = atoi(GetParamN(Params, buf, SIZEOF(buf), 10, ',', 0)); - gl.dwBottom = atoi(GetParamN(Params, buf, SIZEOF(buf), 11, ',', 0)); - gl.dwAlpha = atoi(GetParamN(Params, buf, SIZEOF(buf), 12, ',', 0)); - GetParamN(Params, buf, SIZEOF(buf), 7, ',', 0); + gl.szFileName = mir_strdup(GetParamN(Params, buf, _countof(buf), 2, ',', 0)); + + gl.clipArea.x = atoi(GetParamN(Params, buf, _countof(buf), 3, ',', 0)); + gl.clipArea.y = atoi(GetParamN(Params, buf, _countof(buf), 4, ',', 0)); + gl.szclipArea.cx = atoi(GetParamN(Params, buf, _countof(buf), 5, ',', 0)); + gl.szclipArea.cy = atoi(GetParamN(Params, buf, _countof(buf), 6, ',', 0)); + + gl.dwLeft = atoi(GetParamN(Params, buf, _countof(buf), 8, ',', 0)); + gl.dwTop = atoi(GetParamN(Params, buf, _countof(buf), 9, ',', 0)); + gl.dwRight = atoi(GetParamN(Params, buf, _countof(buf), 10, ',', 0)); + gl.dwBottom = atoi(GetParamN(Params, buf, _countof(buf), 11, ',', 0)); + gl.dwAlpha = atoi(GetParamN(Params, buf, _countof(buf), 12, ',', 0)); + GetParamN(Params, buf, _countof(buf), 7, ',', 0); if (!mir_strcmpi(buf, "TileBoth")) gl.FitMode = FM_TILE_BOTH; else if (!mir_strcmpi(buf, "TileVert")) gl.FitMode = FM_TILE_VERT; else if (!mir_strcmpi(buf, "TileHorz")) gl.FitMode = FM_TILE_HORZ; @@ -641,6 +641,6 @@ int SkinDrawGlyphMask(HDC hdc, RECT *rcSize, RECT *rcClip, MODERNMASK *ModernMas rq.hDC = hdc; rq.rcDestRect = *rcSize; rq.rcClipRect = *rcClip; - mir_strncpy(rq.szObjectID, "Masked draw", SIZEOF(rq.szObjectID)); + mir_strncpy(rq.szObjectID, "Masked draw", _countof(rq.szObjectID)); return ske_Service_DrawGlyph((WPARAM)&rq, (LPARAM)ModernMask); } diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 7d785529e3..1f087a1cb4 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -770,12 +770,12 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa if (msg == WM_LBUTTONDOWN && bCtrl) { if (g_CluiData.bFilterEffective != CLVM_FILTER_PROTOS || !bShift) { ApplyViewMode(""); - mir_snprintf(g_CluiData.protoFilter, SIZEOF(g_CluiData.protoFilter), "%s|", p.szAccountName); + mir_snprintf(g_CluiData.protoFilter, _countof(g_CluiData.protoFilter), "%s|", p.szAccountName); g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS; } else { char protoF[sizeof(g_CluiData.protoFilter)]; - mir_snprintf(protoF, SIZEOF(protoF), "%s|", p.szAccountName); + mir_snprintf(protoF, _countof(protoF), "%s|", p.szAccountName); char *pos = strstri(g_CluiData.protoFilter, p.szAccountName); if (pos) { // remove filter @@ -789,7 +789,7 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa } else { //add filter - mir_snprintf(g_CluiData.protoFilter, SIZEOF(g_CluiData.protoFilter), "%s%s", g_CluiData.protoFilter, protoF); + mir_snprintf(g_CluiData.protoFilter, _countof(g_CluiData.protoFilter), "%s%s", g_CluiData.protoFilter, protoF); g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS; } } @@ -809,11 +809,11 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa continue; char protoF[sizeof(g_CluiData.protoFilter)]; - mir_snprintf(protoF, SIZEOF(protoF), "%s|", accs[i]->szModuleName); + mir_snprintf(protoF, _countof(protoF), "%s|", accs[i]->szModuleName); if (strstri(g_CluiData.protoFilter, protoF)) { if (!first) - mir_strncat(filterName, "; ", SIZEOF(filterName) - mir_strlen(filterName)); - mir_strncat(filterName, T2Utf(accs[i]->tszAccountName), SIZEOF(filterName) - mir_strlen(filterName)); + mir_strncat(filterName, "; ", _countof(filterName) - mir_strlen(filterName)); + mir_strncat(filterName, T2Utf(accs[i]->tszAccountName), _countof(filterName) - mir_strlen(filterName)); first = false; } } diff --git a/plugins/Clist_modern/src/modern_statusbar_options.cpp b/plugins/Clist_modern/src/modern_statusbar_options.cpp index 7625191703..601dad4d04 100644 --- a/plugins/Clist_modern/src/modern_statusbar_options.cpp +++ b/plugins/Clist_modern/src/modern_statusbar_options.cpp @@ -241,14 +241,14 @@ INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { TCHAR *align[] = { LPGENT("Left"), LPGENT("Center"), LPGENT("Right") }; - for (int i = 0; i < SIZEOF(align); i++) + for (int i = 0; i < _countof(align); i++) SendDlgItemMessage(hwndDlg, IDC_SBAR_HORIZ_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(align[i])); SendDlgItemMessage(hwndDlg, IDC_SBAR_HORIZ_ALIGN, CB_SETCURSEL, db_get_b(NULL, "CLUI", "Align", SETTING_ALIGN_DEFAULT), 0); } { TCHAR *align[] = { LPGENT("Top"), LPGENT("Center"), LPGENT("Bottom") }; - for (int i = 0; i < SIZEOF(align); i++) + for (int i = 0; i < _countof(align); i++) SendDlgItemMessage(hwndDlg, IDC_SBAR_VERT_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateTS(align[i])); SendDlgItemMessage(hwndDlg, IDC_SBAR_VERT_ALIGN, CB_SETCURSEL, db_get_b(NULL, "CLUI", "VAlign", SETTING_VALIGN_DEFAULT), 0); } @@ -403,25 +403,25 @@ INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l StatusBarProtocolOptions *sbpo = (StatusBarProtocolOptions*)SendMessage(hwndComboBox, CB_GETITEMDATA, i, 0); char settingBuf[256]; - mir_snprintf(settingBuf, SIZEOF(settingBuf), "SBarAccountIsCustom_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "SBarAccountIsCustom_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->AccountIsCustomized); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "HideAccount_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "HideAccount_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->HideAccount); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "SBarShow_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "SBarShow_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->SBarShow); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "SBarRightClk_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "SBarRightClk_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->SBarRightClk); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "UseConnectingIcon_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "UseConnectingIcon_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->UseConnectingIcon); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "ShowUnreadEmails_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "ShowUnreadEmails_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, (BYTE)sbpo->ShowUnreadEmails); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "ShowXStatus_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "ShowXStatus_%s", sbpo->szName); db_set_b(NULL, "CLUI", settingBuf, sbpo->ShowXStatus); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "PaddingLeft_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "PaddingLeft_%s", sbpo->szName); db_set_dw(NULL, "CLUI", settingBuf, sbpo->PaddingLeft); - mir_snprintf(settingBuf, SIZEOF(settingBuf), "PaddingRight_%s", sbpo->szName); + mir_snprintf(settingBuf, _countof(settingBuf), "PaddingRight_%s", sbpo->szName); db_set_dw(NULL, "CLUI", settingBuf, sbpo->PaddingRight); } diff --git a/plugins/Clist_modern/src/modern_sync.cpp b/plugins/Clist_modern/src/modern_sync.cpp index 68b0927bad..8266c95660 100644 --- a/plugins/Clist_modern/src/modern_sync.cpp +++ b/plugins/Clist_modern/src/modern_sync.cpp @@ -84,7 +84,7 @@ int SyncCall(void * vproc, int count, ...) int i; params[0] = (LPARAM)count; va_start(va, count); - for (i = 0; i < count && i < SIZEOF(params) - 1; i++) + for (i = 0; i < count && i < _countof(params) - 1; i++) params[i + 1] = va_arg(va, LPARAM); va_end(va); diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index 34418e3818..dbf6a79907 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -101,7 +101,7 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint, POINT *pOffset) if (!g_CluiData.fDisableSkinEngine) { char szRequest[128]; /* painting */ - mir_snprintf(szRequest, SIZEOF(szRequest), "Button,ID=%s,Hovered=%s,Pressed=%s,Focused=%s", + mir_snprintf(szRequest, _countof(szRequest), "Button,ID=%s,Hovered=%s,Pressed=%s,Focused=%s", bct->szButtonID, // ID b2str(bct->stateId == PBS_HOT), // Hovered b2str(bct->stateId == PBS_PRESSED || bct->bIsPushed == TRUE), // Pressed @@ -239,7 +239,7 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam break; case WM_SETTEXT: - mir_tstrncpy(bct->szText, (TCHAR*)lParam, SIZEOF(bct->szText)); + mir_tstrncpy(bct->szText, (TCHAR*)lParam, _countof(bct->szText)); break; case WM_SETFONT: diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index 37bd25dacd..2e4cdd5ba4 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -58,7 +58,7 @@ static void SetButtonPressed(int i, int state) void Modern_InitButtons() { - for (int i = 0; i < SIZEOF(BTNS); i++) { + for (int i = 0; i < _countof(BTNS); i++) { TTBButton tbb = { 0 }; tbb.cbSize = sizeof(tbb); diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 9da5d24f42..5bd9b5db27 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -388,11 +388,11 @@ void SaveState() if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; item.pszText = szTemp; - item.cchTextMax = SIZEOF(szTemp); + item.cchTextMax = _countof(szTemp); item.iItem = i; SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); - mir_strncat(newProtoFilter, szTemp, SIZEOF(newProtoFilter) - mir_strlen(newProtoFilter)); - mir_strncat(newProtoFilter, "|", SIZEOF(newProtoFilter) - mir_strlen(newProtoFilter)); + mir_strncat(newProtoFilter, szTemp, _countof(newProtoFilter) - mir_strlen(newProtoFilter)); + mir_strncat(newProtoFilter, "|", _countof(newProtoFilter) - mir_strlen(newProtoFilter)); newProtoFilter[2047] = 0; } } @@ -409,11 +409,11 @@ void SaveState() if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; item.pszText = szTemp; - item.cchTextMax = SIZEOF(szTemp); + item.cchTextMax = _countof(szTemp); item.iItem = i; SendMessage(hwndList, LVM_GETITEM, 0, (LPARAM)&item); - mir_tstrncat(newGroupFilter, szTemp, SIZEOF(newGroupFilter) - mir_tstrlen(newGroupFilter)); - mir_tstrncat(newGroupFilter, _T("|"), SIZEOF(newGroupFilter) - mir_tstrlen(newGroupFilter)); + mir_tstrncat(newGroupFilter, szTemp, _countof(newGroupFilter) - mir_tstrlen(newGroupFilter)); + mir_tstrncat(newGroupFilter, _T("|"), _countof(newGroupFilter) - mir_tstrlen(newGroupFilter)); newGroupFilter[2047] = 0; } } @@ -499,7 +499,7 @@ static void UpdateFilters() SendDlgItemMessage(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szTempBuf); T2Utf szBuf(szTempBuf); - mir_strncpy(g_szModename, szBuf, SIZEOF(g_szModename)); + mir_strncpy(g_szModename, szBuf, _countof(g_szModename)); mir_sntprintf(szTemp, TranslateT("Configuring view mode: %s"), szTempBuf); SetDlgItemText(clvmHwnd, IDC_CURVIEWMODE2, szTemp); @@ -532,12 +532,12 @@ static void UpdateFilters() item.mask = LVIF_TEXT; item.pszText = szTemp; - item.cchTextMax = SIZEOF(szTemp); + item.cchTextMax = _countof(szTemp); for (i = 0; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); - mir_snprintf(szMask, SIZEOF(szMask), "%s|", szTemp); + mir_snprintf(szMask, _countof(szMask), "%s|", szTemp); if (szPF && strstr(szPF, szMask)) ListView_SetCheckState(hwndList, i, TRUE) else @@ -553,14 +553,14 @@ static void UpdateFilters() item.mask = LVIF_TEXT; item.pszText = szTemp; - item.cchTextMax = SIZEOF(szTemp); + item.cchTextMax = _countof(szTemp); ListView_SetCheckState(hwndList, 0, dwFlags & CLVM_INCLUDED_UNGROUPED ? TRUE : FALSE); for (i = 1; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; SendMessage(hwndList, LVM_GETITEM, 0, (LPARAM)&item); - mir_sntprintf(szMask, SIZEOF(szMask), _T("%s|"), szTemp); + mir_sntprintf(szMask, _countof(szMask), _T("%s|"), szTemp); if (szGF && _tcsstr(szGF, szMask)) ListView_SetCheckState(hwndList, i, TRUE) else @@ -770,7 +770,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP { TCHAR szBuf[256]; szBuf[0] = 0; - GetDlgItemText(hwndDlg, IDC_NEWVIEMODE, szBuf, SIZEOF(szBuf)); + GetDlgItemText(hwndDlg, IDC_NEWVIEMODE, szBuf, _countof(szBuf)); szBuf[255] = 0; if (szBuf[0] != 0) { @@ -1262,8 +1262,8 @@ void ApplyViewMode(const char *Name, bool onlySelector) mir_snprintf(szSetting, "%c%s_PF", 246, Name); if (!db_get_s(NULL, CLVM_MODULE, szSetting, &dbv)) { if (mir_strlen(dbv.pszVal) >= 2) { - mir_strncpy(g_CluiData.protoFilter, dbv.pszVal, SIZEOF(g_CluiData.protoFilter)); - g_CluiData.protoFilter[SIZEOF(g_CluiData.protoFilter) - 1] = 0; + mir_strncpy(g_CluiData.protoFilter, dbv.pszVal, _countof(g_CluiData.protoFilter)); + g_CluiData.protoFilter[_countof(g_CluiData.protoFilter) - 1] = 0; g_CluiData.bFilterEffective |= CLVM_FILTER_PROTOS; } mir_free(dbv.pszVal); @@ -1271,8 +1271,8 @@ void ApplyViewMode(const char *Name, bool onlySelector) mir_snprintf(szSetting, "%c%s_GF", 246, Name); if (!db_get_ts(NULL, CLVM_MODULE, szSetting, &dbv)) { if (mir_tstrlen(dbv.ptszVal) >= 2) { - mir_tstrncpy(g_CluiData.groupFilter, dbv.ptszVal, SIZEOF(g_CluiData.groupFilter)); - g_CluiData.groupFilter[SIZEOF(g_CluiData.groupFilter) - 1] = 0; + mir_tstrncpy(g_CluiData.groupFilter, dbv.ptszVal, _countof(g_CluiData.groupFilter)); + g_CluiData.groupFilter[_countof(g_CluiData.groupFilter) - 1] = 0; g_CluiData.bFilterEffective |= CLVM_FILTER_GROUPS; } mir_free(dbv.ptszVal); @@ -1294,7 +1294,7 @@ void ApplyViewMode(const char *Name, bool onlySelector) if (g_CluiData.filterFlags & CLVM_AUTOCLEAR) { mir_snprintf(szSetting, "%c%s_OPT", 246, Name); DWORD timerexpire = LOWORD(db_get_dw(NULL, CLVM_MODULE, szSetting, 0)); - mir_strncpy(g_CluiData.old_viewmode, g_CluiData.current_viewmode, SIZEOF(g_CluiData.old_viewmode)); + mir_strncpy(g_CluiData.old_viewmode, g_CluiData.current_viewmode, _countof(g_CluiData.old_viewmode)); g_CluiData.old_viewmode[255] = 0; CLUI_SafeSetTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE, timerexpire * 1000, NULL); } @@ -1302,7 +1302,7 @@ void ApplyViewMode(const char *Name, bool onlySelector) mir_snprintf(szSetting, "%c_LastMode", 246); db_set_s(NULL, CLVM_MODULE, szSetting, Name); } - mir_strncpy(g_CluiData.current_viewmode, Name, SIZEOF(g_CluiData.current_viewmode)); + mir_strncpy(g_CluiData.current_viewmode, Name, _countof(g_CluiData.current_viewmode)); g_CluiData.current_viewmode[255] = 0; if (g_CluiData.filterFlags & CLVM_USELASTMSG) { -- cgit v1.2.3