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/NewAwaySysMod/src/AwayOpt.cpp | 46 ++++++++++++++--------------- plugins/NewAwaySysMod/src/AwaySys.cpp | 12 ++++---- plugins/NewAwaySysMod/src/Client.cpp | 2 +- plugins/NewAwaySysMod/src/Common.h | 6 ++-- plugins/NewAwaySysMod/src/GroupCheckbox.cpp | 6 ++-- plugins/NewAwaySysMod/src/MsgEventAdded.cpp | 2 +- plugins/NewAwaySysMod/src/MsgTree.cpp | 12 ++++---- plugins/NewAwaySysMod/src/Notification.cpp | 2 +- plugins/NewAwaySysMod/src/Options.cpp | 4 +-- plugins/NewAwaySysMod/src/Properties.cpp | 2 +- plugins/NewAwaySysMod/src/Properties.h | 6 ++-- plugins/NewAwaySysMod/src/ReadAwayMsg.cpp | 8 ++--- plugins/NewAwaySysMod/src/SetAwayMsg.cpp | 10 +++---- 13 files changed, 59 insertions(+), 59 deletions(-) (limited to 'plugins/NewAwaySysMod/src') diff --git a/plugins/NewAwaySysMod/src/AwayOpt.cpp b/plugins/NewAwaySysMod/src/AwayOpt.cpp index 8f70efaf24..38d69042b3 100644 --- a/plugins/NewAwaySysMod/src/AwayOpt.cpp +++ b/plugins/NewAwaySysMod/src/AwayOpt.cpp @@ -138,13 +138,13 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, EM_LIMITTEXT, TREEITEMTITLE_MAXLEN, 0); SendDlgItemMessage(hwndDlg, IDC_MESSAGEDLG_MSGDATA, EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0); // init image buttons - for (int i = 0; i < SIZEOF(Dlg1Buttons); i++) { + for (int i = 0; i < _countof(Dlg1Buttons); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg1Buttons[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Dlg1Buttons[i].Text), BATF_TCHAR); SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0); } // now default status message buttons - for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg1DefMsgDlgItems); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg1DefMsgDlgItems[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg1DefMsgDlgItems[i].Status, 0), BATF_TCHAR); SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0); @@ -162,10 +162,10 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP return true; case UM_ICONSCHANGED: - for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) + for (int i = 0; i < _countof(Dlg1DefMsgDlgItems); i++) SendDlgItemMessage(hwndDlg, Dlg1DefMsgDlgItems[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg1DefMsgDlgItems[i].IconIndex]); - for (int i = 0; i < SIZEOF(Dlg1Buttons); i++) + for (int i = 0; i < _countof(Dlg1Buttons); i++) if (Dlg1Buttons[i].IconIndex != ILI_NOICON) SendDlgItemMessage(hwndDlg, Dlg1Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg1Buttons[i].IconIndex]); @@ -212,7 +212,7 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category.")); } } - for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg1DefMsgDlgItems); i++) { COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(Dlg1DefMsgDlgItems[i].DlgItem); Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(Dlg1DefMsgDlgItems[i].Status) == pnm->ItemNew->ID); } @@ -227,7 +227,7 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP _ASSERT(SelectedItem); // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID)) { - for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg1DefMsgDlgItems); i++) { COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(Dlg1DefMsgDlgItems[i].DlgItem); Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(Dlg1DefMsgDlgItems[i].Status) == SelectedItem->ID); } @@ -272,7 +272,7 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_MESSAGEDLG_DEF_INV: case IDC_MESSAGEDLG_DEF_OTP: case IDC_MESSAGEDLG_DEF_OTL: - for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg1DefMsgDlgItems); i++) { if (LOWORD(wParam) == Dlg1DefMsgDlgItems[i].DlgItem) { MsgTree->SetDefMsg(Dlg1DefMsgDlgItems[i].Status, MsgTree->GetSelection()->ID); // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more break; @@ -373,7 +373,7 @@ static INT_PTR CALLBACK MoreOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_WAITFORMSG_SPIN, UDM_SETRANGE32, -1, 9999); SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_RECENTMSGSCOUNT_SPIN, UDM_SETRANGE32, 0, 99); SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_UPDATEMSGSPERIOD_SPIN, UDM_SETRANGE32, 30, 99999); - for (int i = 0; i < SIZEOF(Dlg2StatusButtons); i++) { + for (int i = 0; i < _countof(Dlg2StatusButtons); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg2StatusButtons[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg2StatusButtons[i].Status, 0), BATF_TCHAR); SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0); @@ -386,7 +386,7 @@ static INT_PTR CALLBACK MoreOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return true; case UM_ICONSCHANGED: - for (int i = 0; i < SIZEOF(Dlg2StatusButtons); i++) + for (int i = 0; i < _countof(Dlg2StatusButtons); i++) SendDlgItemMessage(hwndDlg, Dlg2StatusButtons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg2StatusButtons[i].IconIndex]); break; @@ -523,10 +523,10 @@ INT_PTR CALLBACK AutoreplyOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l _T("Miranda"), AUTOREPLY_IDLE_MIRANDA }; - for (int i = 0; i < SIZEOF(IdleComboValues); i++) + for (int i = 0; i < _countof(IdleComboValues); i++) SendMessage(hCombo, CB_SETITEMDATA, SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(IdleComboValues[i].Text)), IdleComboValues[i].Meaning); - for (int i = 0; i < SIZEOF(Dlg3StatusButtons); i++) { + for (int i = 0; i < _countof(Dlg3StatusButtons); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg3StatusButtons[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg3StatusButtons[i].Status, 0), BATF_TCHAR); SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0); @@ -557,7 +557,7 @@ INT_PTR CALLBACK AutoreplyOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.hwnd = hwndDlg; - for (int i = 0; i < SIZEOF(Tooltips); i++) { + for (int i = 0; i < _countof(Tooltips); i++) { ti.uId = (UINT)GetDlgItem(hwndDlg, Tooltips[i].DlgItemID); ti.lpszText = TranslateTS(Tooltips[i].Text); SendMessage(hWndTooltips, TTM_ADDTOOL, 0, (LPARAM)&ti); @@ -573,7 +573,7 @@ INT_PTR CALLBACK AutoreplyOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return true; case UM_ICONSCHANGED: - for (int i = 0; i < SIZEOF(Dlg3StatusButtons); i++) + for (int i = 0; i < _countof(Dlg3StatusButtons); i++) SendDlgItemMessage(hwndDlg, Dlg3StatusButtons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg3StatusButtons[i].IconIndex]); variables_skin_helpbutton(hwndDlg, IDC_REPLYDLG_VARS); @@ -693,13 +693,13 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hwndDlg, IDC_MESSAGEDLG_MSGDATA, EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0); // init image buttons - for (int i = 0; i < SIZEOF(Dlg4Buttons); i++) { + for (int i = 0; i < _countof(Dlg4Buttons); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg4Buttons[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Dlg4Buttons[i].Text), BATF_TCHAR); SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0); } // now default status message buttons - for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg4DefMsgDlgItems); i++) { HWND hButton = GetDlgItem(hwndDlg, Dlg4DefMsgDlgItems[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg4DefMsgDlgItems[i].Status, 0), BATF_TCHAR); SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0); @@ -717,10 +717,10 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA return true; case UM_ICONSCHANGED: - for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) + for (int i = 0; i < _countof(Dlg4DefMsgDlgItems); i++) SendDlgItemMessage(hwndDlg, Dlg4DefMsgDlgItems[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg4DefMsgDlgItems[i].IconIndex]); - for (int i = 0; i < SIZEOF(Dlg4Buttons); i++) + for (int i = 0; i < _countof(Dlg4Buttons); i++) if (Dlg4Buttons[i].IconIndex != ILI_NOICON) SendDlgItemMessage(hwndDlg, Dlg4Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Dlg4Buttons[i].IconIndex]); @@ -767,7 +767,7 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category.")); } } - for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg4DefMsgDlgItems); i++) { COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(Dlg4DefMsgDlgItems[i].DlgItem); Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(Dlg4DefMsgDlgItems[i].Status) == pnm->ItemNew->ID); } @@ -781,7 +781,7 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA CBaseTreeItem* SelectedItem = MsgTree->GetSelection(); _ASSERT(SelectedItem); if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID)) { // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected - for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg4DefMsgDlgItems); i++) { COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(Dlg4DefMsgDlgItems[i].DlgItem); Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(Dlg4DefMsgDlgItems[i].Status) == SelectedItem->ID); } @@ -826,7 +826,7 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case IDC_MESSAGEDLG_DEF_INV: case IDC_MESSAGEDLG_DEF_OTP: case IDC_MESSAGEDLG_DEF_OTL: - for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(Dlg4DefMsgDlgItems); i++) { if (LOWORD(wParam) == Dlg4DefMsgDlgItems[i].DlgItem) { // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more MsgTree->SetDefMsg(Dlg4DefMsgDlgItems[i].Status, MsgTree->GetSelection()->ID); @@ -952,7 +952,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem); - for (int i = 0; i < SIZEOF(Icons); i++) { + for (int i = 0; i < _countof(Icons); i++) { int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0)); if (Icons[i] == 0xFF) Icons[i] = Icon; @@ -963,7 +963,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt } hItem = (FirstItemType == CLCIT_CONTACT) ? hFirstItem : (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - for (int i = 0; i < SIZEOF(Icons); i++) { + for (int i = 0; i < _countof(Icons); i++) { int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0)); if (Icons[i] == 0xFF) Icons[i] = Icon; @@ -974,7 +974,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt } // set icons - for (int i = 0; i < SIZEOF(Icons); i++) + for (int i = 0; i < _countof(Icons); i++) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, Icons[i])); } diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 90976f1d3c..769ec125ae 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -231,7 +231,7 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) } int i; - for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--) + for (i = _countof(StatusModeList) - 1; i >= 0; i--) if (wParam == StatusModeList[i].Status) break; if (i < 0) @@ -300,20 +300,20 @@ int PreBuildContactMenu(WPARAM hContact, LPARAM) TCHAR szSetStr[256], szReadStr[256]; if (szProto) { int i; - for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--) + for (i = _countof(StatusModeList) - 1; i >= 0; i--) if (iMode == StatusModeList[i].Status) break; // the protocol supports status message sending for current status, or autoreplying if ((Flag1 & PF1_MODEMSGSEND && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iMode)) || ((Flag1 & PF1_IM) == PF1_IM && (i < 0 || !g_AutoreplyOptPage.GetDBValueCopy(StatusModeList[i].DisableReplyCtlID)))) { - mir_sntprintf(szSetStr, SIZEOF(szSetStr), TranslateT("Set %s message for the contact"), pcli->pfnGetStatusModeDescription(iMode, 0), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(szSetStr, _countof(szSetStr), TranslateT("Set %s message for the contact"), pcli->pfnGetStatusModeDescription(iMode, 0), pcli->pfnGetContactDisplayName(hContact, 0)); miSetMsg.ptszName = szSetStr; miSetMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME; } // the protocol supports status message reading for contact's status if (Flag1 & PF1_MODEMSGRECV && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iContactMode)) { - mir_sntprintf(szReadStr, SIZEOF(szReadStr), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iContactMode, 0)); + mir_sntprintf(szReadStr, _countof(szReadStr), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iContactMode, 0)); miReadMsg.ptszName = szReadStr; miReadMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME | CMIM_ICON; miReadMsg.hIcon = Skin_LoadProtoIcon(szProto, iContactMode); @@ -692,7 +692,7 @@ int MirandaLoaded(WPARAM, LPARAM) tr.szService = MS_AWAYSYS_VARIABLESHANDLER; tr.szCleanupService = MS_AWAYSYS_FREEVARMEM; tr.memType = TR_MEM_OWNER; - for (int i = 0; i < SIZEOF(Variables); i++) { + for (int i = 0; i < _countof(Variables); i++) { tr.flags = Variables[i].Flags | TRF_CALLSVC | TRF_TCHAR; tr.tszTokenString = Variables[i].Name; tr.szHelpText = Variables[i].Descr; @@ -713,7 +713,7 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded); - Icon_Register(g_hInstance, MOD_NAME, iconList, SIZEOF(iconList), "nas"); + Icon_Register(g_hInstance, MOD_NAME, iconList, _countof(iconList), "nas"); InitCommonControls(); InitOptions(); // must be called before we hook CallService diff --git a/plugins/NewAwaySysMod/src/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index 827bd0be7c..6790efa6b2 100644 --- a/plugins/NewAwaySysMod/src/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -123,7 +123,7 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) ID_STATUS_IDLE, "Idl" }; - for (int i = 0; i < SIZEOF(StatusSettings); i++) { + for (int i = 0; i < _countof(StatusSettings); i++) { if (iMode == StatusSettings[i].Status) { db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Msg", CurMsg); db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ? diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index 36b036c619..cc744ea932 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -153,8 +153,8 @@ #define DB_SETTINGSVER "SettingsVer" -#ifndef SIZEOF -#define SIZEOF(s) (sizeof(s) / sizeof(*s)) +#ifndef _countof +#define _countof(s) (sizeof(s) / sizeof(*s)) #endif #define UM_ICONSCHANGED (WM_USER + 121) @@ -322,7 +322,7 @@ static __inline int LogMessage(const char *Format, ...) char szText[8096]; mir_strcpy(szText, LOG_PREFIX); va_start(va, Format); - mir_vsnprintf(szText + (SIZEOF(LOG_PREFIX) - 1), sizeof(szText) - (SIZEOF(LOG_PREFIX) - 1), Format, va); + mir_vsnprintf(szText + (_countof(LOG_PREFIX) - 1), sizeof(szText) - (_countof(LOG_PREFIX) - 1), Format, va); va_end(va); return CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText); } diff --git a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp index 1cc6c21e01..7c66b0eff1 100644 --- a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp +++ b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp @@ -44,8 +44,8 @@ #define CGSM_ISCHECKED 3 // mask for BM_GETCHECK #define CGSM_GETSTATE 7 // mask to get only valid values for BM_GETSTATE -#ifndef SIZEOF -#define SIZEOF(s) (sizeof(s) / sizeof(*s)) +#ifndef _countof +#define _countof(s) (sizeof(s) / sizeof(*s)) #endif class CCheckboxData @@ -266,7 +266,7 @@ static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l { 0, 0, DFCS_PUSHED, DFCS_INACTIVE, DFCS_CHECKED, DFCS_CHECKED, DFCS_CHECKED | DFCS_PUSHED, DFCS_CHECKED | DFCS_INACTIVE, DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED }; - _ASSERT(StateID >= 1 && StateID <= SIZEOF(dfcStates)); + _ASSERT(StateID >= 1 && StateID <= _countof(dfcStates)); DrawFrameControl(hdcMem, &rc, DFC_BUTTON, dfcStates[StateID - 1]); } diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 20411a6b86..7290ada575 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -175,7 +175,7 @@ int MsgEventAdded(WPARAM hContact, LPARAM lParam) unsigned int iMode = CallProtoService(szProto, PS_GETSTATUS, 0, 0); int i; - for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--) + for (i = _countof(StatusModeList) - 1; i >= 0; i--) if (iMode == StatusModeList[i].Status) break; diff --git a/plugins/NewAwaySysMod/src/MsgTree.cpp b/plugins/NewAwaySysMod/src/MsgTree.cpp index 921c52d620..4eb3f9ba12 100644 --- a/plugins/NewAwaySysMod/src/MsgTree.cpp +++ b/plugins/NewAwaySysMod/src/MsgTree.cpp @@ -174,7 +174,7 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L TreeView_GetItemRect(lpNMCD->nmcd.hdr.hwndFrom, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, true); int iSize = GetSystemMetrics(SM_CXSMICON); int x = rc.left - iSize - 5; - for (int i = 0; i < SIZEOF(SettingsList); i++) { + for (int i = 0; i < _countof(SettingsList); i++) { if (lpNMCD->nmcd.lItemlParam == dat->MsgTreePage.GetValue(SettingsList[i].DBSetting)) { DrawIconEx(lpNMCD->nmcd.hdc, x, rc.top, Skin_LoadProtoIcon(NULL, SettingsList[i].Status), iSize, iSize, 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL); x -= iSize + 1; @@ -391,13 +391,13 @@ static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, mii.fMask = MIIM_BITMAP | MIIM_DATA | MIIM_STATE | MIIM_CHECKMARKS; mii.hbmpItem = HBMMENU_CALLBACK; int i; - for (i = 0; i < SIZEOF(MenuItems); i++) { // set icons + for (i = 0; i < _countof(MenuItems); i++) { // set icons mii.dwItemData = MenuItems[i].IconID; SetMenuItemInfo(hPopupMenu, MenuItems[i].ItemID, false, &mii); } mii.fMask = MIIM_STATE; mii.fState = MFS_CHECKED; - for (i = 0; i < SIZEOF(SettingsList); i++) // set checkmarks + for (i = 0; i < _countof(SettingsList); i++) // set checkmarks if (TreeCtrl->Value[Order].ID == dat->MsgTreePage.GetValue(SettingsList[i].DBSetting)) SetMenuItemInfo(hPopupMenu, SettingsList[i].MenuItemID, false, &mii); @@ -424,7 +424,7 @@ static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, case IDR_MSGTREEMENU_DEF_INV: case IDR_MSGTREEMENU_DEF_OTP: case IDR_MSGTREEMENU_DEF_OTL: - for (int i = 0; i < SIZEOF(SettingsList); i++) { + for (int i = 0; i < _countof(SettingsList); i++) { if (SettingsList[i].MenuItemID == MenuResult) { dat->SetDefMsg(SettingsList[i].Status, tvi.lParam); break; @@ -513,7 +513,7 @@ bool CMsgTree::SetSelection(int ID, int Flags) // set ID = -1 to unselect; retur int CMsgTree::GetDefMsg(int iMode) { - for (int i = 0; i < SIZEOF(SettingsList); i++) + for (int i = 0; i < _countof(SettingsList); i++) if (SettingsList[i].Status == iMode) return MsgTreePage.GetValue(SettingsList[i].DBSetting); @@ -522,7 +522,7 @@ int CMsgTree::GetDefMsg(int iMode) void CMsgTree::SetDefMsg(int iMode, int ID) { - for (int i = 0; i < SIZEOF(SettingsList); i++) { + for (int i = 0; i < _countof(SettingsList); i++) { if (SettingsList[i].Status == iMode) { if (MsgTreePage.GetValue(SettingsList[i].DBSetting) != ID) { RECT rc; diff --git a/plugins/NewAwaySysMod/src/Notification.cpp b/plugins/NewAwaySysMod/src/Notification.cpp index 6ef034d2f9..6527a0731b 100644 --- a/plugins/NewAwaySysMod/src/Notification.cpp +++ b/plugins/NewAwaySysMod/src/Notification.cpp @@ -69,7 +69,7 @@ void ShowLog(TCString &LogFilePath) int Result = (int)ShellExecute(NULL, _T("open"), LogFilePath, NULL, NULL, SW_SHOW); if (Result <= 32) { TCHAR szError[64]; - mir_sntprintf(szError, SIZEOF(szError), TranslateT("Error #%d"), Result); + mir_sntprintf(szError, _countof(szError), TranslateT("Error #%d"), Result); ShowMsg(szError, TranslateT("Can't open log file ") + LogFilePath, true); } } diff --git a/plugins/NewAwaySysMod/src/Options.cpp b/plugins/NewAwaySysMod/src/Options.cpp index 1c3dfe98a0..5610280b56 100644 --- a/plugins/NewAwaySysMod/src/Options.cpp +++ b/plugins/NewAwaySysMod/src/Options.cpp @@ -263,7 +263,7 @@ typedef struct int TreeReadEnum(const char *szSetting, LPARAM lParam) { sTreeReadEnumData *TreeReadEnumData = (sTreeReadEnumData*)lParam; - int Len = TreeReadEnumData->TreeCtrl->sDBSetting.GetLen() + SIZEOF(TREEITEM_DBSTR_TITLE) - 1; + int Len = TreeReadEnumData->TreeCtrl->sDBSetting.GetLen() + _countof(TREEITEM_DBSTR_TITLE) - 1; if (!strncmp(szSetting, TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_TITLE, Len) && isdigit(szSetting[Len])) { int ID = atol(szSetting + Len); short ParentID = (TreeReadEnumData->TreeCtrl->TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) ? 0 : db_get_w(NULL, *TreeReadEnumData->sModule, @@ -648,7 +648,7 @@ typedef struct int ListReadEnum(const char *szSetting, LPARAM lParam) { sListReadEnumData *ListReadEnumData = (sListReadEnumData*)lParam; - int Len = ListReadEnumData->sDBSettingPrefix->GetLen() + ListReadEnumData->ListCtrl->sDBSetting.GetLen() + SIZEOF(LISTITEM_DBSTR_TEXT) - 1; + int Len = ListReadEnumData->sDBSettingPrefix->GetLen() + ListReadEnumData->ListCtrl->sDBSetting.GetLen() + _countof(LISTITEM_DBSTR_TEXT) - 1; if (!strncmp(szSetting, *ListReadEnumData->sDBSettingPrefix + ListReadEnumData->ListCtrl->sDBSetting + LISTITEM_DBSTR_TEXT, Len) && isdigit(szSetting[Len])) { int ID = atol(szSetting + Len); ListReadEnumData->ListCtrl->Value.SetAtGrow(ID).Text = db_get_s(NULL, *ListReadEnumData->sModule, *ListReadEnumData->sDBSettingPrefix + szSetting, _T("")); diff --git a/plugins/NewAwaySysMod/src/Properties.cpp b/plugins/NewAwaySysMod/src/Properties.cpp index 74b21baf71..baac915742 100644 --- a/plugins/NewAwaySysMod/src/Properties.cpp +++ b/plugins/NewAwaySysMod/src/Properties.cpp @@ -314,7 +314,7 @@ TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder) IDS_MESSAGEDLG_DEF_OTL, ID_STATUS_OUTTOLUNCH }; - for (int i = 0; i < SIZEOF(DefMsgDlgItems); i++) { + for (int i = 0; i < _countof(DefMsgDlgItems); i++) { if (DefMsgDlgItems[i].Status == Status) { DefMsgID = MsgTreeData.GetDBValue(DefMsgDlgItems[i].DBSetting); break; diff --git a/plugins/NewAwaySysMod/src/Properties.h b/plugins/NewAwaySysMod/src/Properties.h index c0dbd1dab7..50c3ee4762 100644 --- a/plugins/NewAwaySysMod/src/Properties.h +++ b/plugins/NewAwaySysMod/src/Properties.h @@ -123,7 +123,7 @@ public: int cxIcon = GetSystemMetrics(SM_CXSMICON); int cyIcon = GetSystemMetrics(SM_CYSMICON); int i; - for (i = 0; i < SIZEOF(Icons); i++) { + for (i = 0; i < _countof(Icons); i++) { if (IconList.GetSize() > i && IconList[i]) DestroyIcon(IconList[i]); @@ -317,7 +317,7 @@ public: CString ProtoStatusToDBSetting(const char *Prefix, int MoreOpt_PerStatusID = 0) { if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID)) { - for (int i = 0; i < SIZEOF(StatusSettings); i++) + for (int i = 0; i < _countof(StatusSettings); i++) if (Status == StatusSettings[i].Status) return szProto ? (CString(Prefix) + "_" + szProto + "_" + StatusSettings[i].Setting) : (CString(Prefix) + StatusSettings[i].Setting); } @@ -381,7 +381,7 @@ public: __inline CString StatusToDBSetting(int Status, const char *Prefix, int MoreOpt_PerStatusID = 0) { if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID)) - for (int i = 0; i < SIZEOF(StatusSettings); i++) + for (int i = 0; i < _countof(StatusSettings); i++) if (Status == StatusSettings[i].Status) return CString(Prefix) + StatusSettings[i].Setting; diff --git a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp index f1018316b8..2988164015 100644 --- a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp @@ -69,11 +69,11 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam TCHAR *contactName = pcli->pfnGetContactDisplayName(awayData->hContact, 0); char *szProto = GetContactProto(awayData->hContact); TCHAR *status = pcli->pfnGetStatusModeDescription(db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status, contactName); + GetWindowText(hwndDlg, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status, contactName); SetWindowText(hwndDlg, str); - GetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status); + GetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status); SetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, str); } return true; diff --git a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index a485cd6097..d91cae662f 100644 --- a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -434,7 +434,7 @@ void UpdateCheckboxesState(CCList *CList) HICON g_LoadIconEx(const char* name, bool big) { char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", "", name); + mir_snprintf(szSettingName, _countof(szSettingName), "%s_%s", "", name); return IcoLib_GetIcon(szSettingName, big); } @@ -601,7 +601,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } // init image buttons - for (int i = 0; i < SIZEOF(Buttons); i++) { + for (int i = 0; i < _countof(Buttons); i++) { HWND hButton = GetDlgItem(hwndDlg, Buttons[i].DlgItem); SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Buttons[i].Text), BATF_TCHAR); SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0); @@ -612,7 +612,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA hWndTooltips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandleA("mir_app.dll"), NULL); ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - for (int i = 0; i < SIZEOF(Tooltips); i++) { + for (int i = 0; i < _countof(Tooltips); i++) { ti.uId = (UINT_PTR)GetDlgItem(hwndDlg, Tooltips[i].DlgItemID); ti.lpszText = TranslateTS(Tooltips[i].Text); SendMessage(hWndTooltips, TTM_ADDTOOL, 0, (LPARAM)&ti); @@ -849,7 +849,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA return true; } TCHAR BtnTitle[64]; - mir_sntprintf(BtnTitle, SIZEOF(BtnTitle), TranslateT("Closing in %d"), Countdown); + mir_sntprintf(BtnTitle, _countof(BtnTitle), TranslateT("Closing in %d"), Countdown); SetDlgItemText(hwndDlg, IDC_OK, BtnTitle); Countdown--; } @@ -1013,7 +1013,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA break; case UM_ICONSCHANGED: - for (int i = 0; i < SIZEOF(Buttons); i++) + for (int i = 0; i < _countof(Buttons); i++) if (Buttons[i].IconIndex != ILI_NOICON) SendDlgItemMessage(hwndDlg, Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[i].IconIndex]); -- cgit v1.2.3