diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/KeyboardNotify/src | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/KeyboardNotify/src')
-rw-r--r-- | plugins/KeyboardNotify/src/ignore.cpp | 10 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/keyboard.cpp | 8 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/options.cpp | 24 |
4 files changed, 23 insertions, 23 deletions
diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index 2a6bf1080f..a02ea38828 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -59,7 +59,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if(hChildItem)
SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for (i=0; i < SIZEOF(iconOn); i++)
+ for (i=0; i < _countof(iconOn); i++)
if(iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0)
iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
@@ -70,7 +70,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while(hItem) {
- for (i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < _countof(iconOn); i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if(iconOn[i] && iImage == 0)
iconOn[i] = 0;
@@ -80,7 +80,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < _countof(iconOn); i++) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0):EMPTY_EXTRA_ICON));
if(groupChildCount)
groupChildCount[i] += childCount[i];
@@ -210,7 +210,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_EVENT_FILE));
ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_MIRANDA));
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- for (i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < _countof(hIcons); i++)
hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL);
}
SendDlgItemMessage(hwndDlg, IDC_ALLICON, STM_SETICON, (WPARAM)hIcons[0], 0);
@@ -317,7 +317,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_DESTROY:
{ int i;
HIMAGELIST hIml;
- for (i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < _countof(hIcons); i++)
DestroyIcon(hIcons[i]);
hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
diff --git a/plugins/KeyboardNotify/src/keyboard.cpp b/plugins/KeyboardNotify/src/keyboard.cpp index 3ce6d8cba3..ee6abec586 100644 --- a/plugins/KeyboardNotify/src/keyboard.cpp +++ b/plugins/KeyboardNotify/src/keyboard.cpp @@ -51,11 +51,11 @@ BOOL OpenKeyboardDevice() TCHAR aux1[MAX_PATH+1], aux2[MAX_PATH+1];
do {
- mir_sntprintf(aux1, SIZEOF(aux1), _T("Kbd%d"), i);
- mir_sntprintf(aux2, SIZEOF(aux2), _T("\\Device\\KeyboardClass%d"), i);
+ mir_sntprintf(aux1, _countof(aux1), _T("Kbd%d"), i);
+ mir_sntprintf(aux2, _countof(aux2), _T("\\Device\\KeyboardClass%d"), i);
DefineDosDevice(DDD_RAW_TARGET_PATH, aux1, aux2);
- mir_sntprintf(aux1, SIZEOF(aux1), _T("\\\\.\\Kbd%d"), i);
+ mir_sntprintf(aux1, _countof(aux1), _T("\\\\.\\Kbd%d"), i);
hKbdDev[i] = CreateFile(aux1, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
} while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES);
@@ -91,7 +91,7 @@ void CloseKeyboardDevice() if (hKbdDev[i] != INVALID_HANDLE_VALUE)
CloseHandle(hKbdDev[i]);
- mir_sntprintf(aux, SIZEOF(aux), _T("Kbd%d"), i);
+ mir_sntprintf(aux, _countof(aux), _T("Kbd%d"), i);
DefineDosDevice(DDD_REMOVE_DEFINITION, aux, NULL);
} while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES);
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index d3d18ab646..4b41e844a5 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -721,9 +721,9 @@ static int ModulesLoaded(WPARAM, LPARAM) // Create some synchronisation objects createEventPrefix(eventPrefix, MAX_PATH - 11); - mir_sntprintf(eventName, SIZEOF(eventName), _T("%s/FlashEvent"), eventPrefix); + mir_sntprintf(eventName, _countof(eventName), _T("%s/FlashEvent"), eventPrefix); hFlashEvent = CreateEvent(NULL, FALSE, FALSE, eventName); - mir_sntprintf(eventName, SIZEOF(eventName), _T("%s/ExitEvent"), eventPrefix); + mir_sntprintf(eventName, _countof(eventName), _T("%s/ExitEvent"), eventPrefix); hExitEvent = CreateEvent(NULL, FALSE, FALSE, eventName); hThread = mir_forkthread(FlashThreadFunction, 0); diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp index a0b31b6e55..50e34cc3c8 100644 --- a/plugins/KeyboardNotify/src/options.cpp +++ b/plugins/KeyboardNotify/src/options.cpp @@ -758,7 +758,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); break; case CBN_EDITCHANGE: - GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme)); + GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme)); if ((item = SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)theme)) == CB_ERR) { //new theme SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, _T("")); EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), TRUE); @@ -780,13 +780,13 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if(HIWORD(wParam) == EN_CHANGE) { TCHAR theme[MAX_PATH+1], customAux[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme)); + GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme)); int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme); if (item == CB_ERR) return TRUE; str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0); if (str) { - GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, customAux, SIZEOF(customAux)); + GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, customAux, _countof(customAux)); if (mir_wstrcmp(str, customAux)) EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), TRUE); else @@ -798,7 +798,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { TCHAR custom[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, custom, SIZEOF(custom)); + GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, custom, _countof(custom)); SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, normalizeCustomString(custom)); testSequence(custom); } @@ -807,7 +807,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { TCHAR theme[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme)); + GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme)); if (!theme[0]) return TRUE; int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme); @@ -827,7 +827,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { TCHAR theme[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme)); + GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme)); int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme); str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0); if (str) { @@ -842,7 +842,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { TCHAR theme[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme)); + GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme)); int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme); str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0); if (str) @@ -884,7 +884,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ofn.lpstrFilter = filter; ofn.lpstrFile = path; ofn.Flags = OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_NOREADONLYRETURN|OFN_PATHMUSTEXIST; - ofn.nMaxFile = SIZEOF(path); + ofn.nMaxFile = _countof(path); ofn.lpstrDefExt = _T("knt"); if(GetSaveFileName(&ofn)) exportThemes(path); @@ -912,7 +912,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ofn.lpstrFilter = filter; ofn.lpstrFile = path; ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR; - ofn.nMaxFile = SIZEOF(path); + ofn.nMaxFile = _countof(path); ofn.lpstrDefExt = _T("knt"); if(GetOpenFileName(&ofn)) { importThemes(path, IsDlgButtonChecked(hwndDlg, IDC_OVERRIDE) == BST_CHECKED); @@ -1115,7 +1115,7 @@ INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), TRUE); break; case CBN_EDITCHANGE: - GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, SIZEOF(szFileName)); + GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName)); if ((item = SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)szFileName)) == CB_ERR) { //new program EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), FALSE); @@ -1131,7 +1131,7 @@ INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM int item; TCHAR szFileName[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, SIZEOF(szFileName)); + GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName)); if (!szFileName[0]) break; item = SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_ADDSTRING, 0, (LPARAM)szFileName); @@ -1144,7 +1144,7 @@ INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM int item; TCHAR szFileName[MAX_PATH+1]; - GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, SIZEOF(szFileName)); + GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName)); item = SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_FINDSTRINGEXACT, -1, (LPARAM)szFileName); SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_DELETESTRING, (WPARAM)item, 0); if (SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETCOUNT, 0, 0) == 0) { |