regedit: Replace the COUNT_OF macro with ARRAY_SIZE.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2018-05-21 13:34:49 +00:00 committed by Alexandre Julliard
parent 5443f0ee2b
commit 78732a6d46
7 changed files with 19 additions and 19 deletions

View File

@ -29,6 +29,6 @@ void ShowAboutBox(HWND hWnd)
{
WCHAR title[64];
HICON icon = LoadImageW( hInst, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, 48, 48, LR_SHARED );
LoadStringW(hInst, IDS_APP_TITLE, title, COUNT_OF(title));
LoadStringW(hInst, IDS_APP_TITLE, title, ARRAY_SIZE(title));
ShellAboutW(hWnd, title, NULL, icon);
}

View File

@ -54,8 +54,8 @@ static int vmessagebox(HWND hwnd, int buttons, int titleId, int resId, __ms_va_l
WCHAR *str;
int ret;
LoadStringW(hInst, titleId, title, COUNT_OF(title));
LoadStringW(hInst, resId, fmt, COUNT_OF(fmt));
LoadStringW(hInst, titleId, title, ARRAY_SIZE(title));
LoadStringW(hInst, resId, fmt, ARRAY_SIZE(fmt));
FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
fmt, 0, 0, (WCHAR *)&str, 0, &va_args);
@ -94,7 +94,7 @@ static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
WCHAR buf[128];
DWORD val;
if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, COUNT_OF(buf))) return FALSE;
if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf))) return FALSE;
if (!swscanf(buf, toHex ? percent_u : percent_x, &val)) return FALSE;
wsprintfW(buf, toHex ? percent_x : percent_u, val);
return SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf);
@ -244,7 +244,7 @@ BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
goto done;
}
if (!LoadStringW(GetModuleHandleW(0), IDS_NEWKEY, newKey, COUNT_OF(newKey))) goto done;
if (!LoadStringW(GetModuleHandleW(0), IDS_NEWKEY, newKey, ARRAY_SIZE(newKey))) goto done;
/* try to find a name for the key being created (maximum = 100 attempts) */
for (keyNum = 1; keyNum < 100; keyNum++) {
@ -460,7 +460,7 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
return FALSE;
}
if (!LoadStringW(GetModuleHandleW(0), IDS_NEWVALUE, newValue, COUNT_OF(newValue))) goto done;
if (!LoadStringW(GetModuleHandleW(0), IDS_NEWVALUE, newValue, ARRAY_SIZE(newValue))) goto done;
/* try to find a name for the value being created (maximum = 100 attempts) */
for (valueNum = 1; valueNum < 100; valueNum++) {

View File

@ -167,7 +167,7 @@ static void update_new_items_and_copy_keyname(HMENU hMenu, WCHAR *keyName)
if (!keyName)
state = MF_GRAYED;
for (i = 0; i < COUNT_OF(items); i++)
for (i = 0; i < ARRAY_SIZE(items); i++)
EnableMenuItem(hMenu, items[i], state | MF_BYCOMMAND);
}
@ -469,7 +469,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
InitOpenFileName(hWnd, &ofn);
ofn.Flags |= OFN_ENABLESIZING;
LoadStringW(hInst, IDS_FILEDIALOG_IMPORT_TITLE, title, COUNT_OF(title));
LoadStringW(hInst, IDS_FILEDIALOG_IMPORT_TITLE, title, ARRAY_SIZE(title));
ofn.lpstrTitle = title;
if (GetOpenFileNameW(&ofn)) {
if (!import_registry_filename(ofn.lpstrFile)) {
@ -498,7 +498,7 @@ static BOOL ExportRegistryFile(HWND hWnd)
WCHAR title[128];
InitOpenFileName(hWnd, &ofn);
LoadStringW(hInst, IDS_FILEDIALOG_EXPORT_TITLE, title, COUNT_OF(title));
LoadStringW(hInst, IDS_FILEDIALOG_EXPORT_TITLE, title, ARRAY_SIZE(title));
ofn.lpstrTitle = title;
ofn.Flags = OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
@ -676,7 +676,7 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
item.mask = TVIF_HANDLE | TVIF_TEXT;
item.hItem = selected;
item.pszText = buf;
item.cchTextMax = COUNT_OF(buf);
item.cchTextMax = ARRAY_SIZE(buf);
SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETITEMW, 0, (LPARAM)&item);
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
@ -1065,10 +1065,10 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
CreateWindowExW(0, szChildClass, captionW, WS_CHILD | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, NULL, hInst, 0);
LoadStringW(hInst, IDS_EXPAND, expandW, COUNT_OF(expandW));
LoadStringW(hInst, IDS_COLLAPSE, collapseW, COUNT_OF(collapseW));
LoadStringW(hInst, IDS_EDIT_MODIFY, modifyW, COUNT_OF(modifyW));
LoadStringW(hInst, IDS_EDIT_MODIFY_BIN, modify_binaryW, COUNT_OF(modify_binaryW));
LoadStringW(hInst, IDS_EXPAND, expandW, ARRAY_SIZE(expandW));
LoadStringW(hInst, IDS_COLLAPSE, collapseW, ARRAY_SIZE(collapseW));
LoadStringW(hInst, IDS_EDIT_MODIFY, modifyW, ARRAY_SIZE(modifyW));
LoadStringW(hInst, IDS_EDIT_MODIFY_BIN, modify_binaryW, ARRAY_SIZE(modify_binaryW));
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam))

View File

@ -361,7 +361,7 @@ HWND CreateListView(HWND hwndParent, UINT id)
WCHAR ListView[] = {'L','i','s','t',' ','V','i','e','w',0};
/* prepare strings */
LoadStringW(hInst, IDS_REGISTRY_VALUE_NOT_SET, g_szValueNotSet, COUNT_OF(g_szValueNotSet));
LoadStringW(hInst, IDS_REGISTRY_VALUE_NOT_SET, g_szValueNotSet, ARRAY_SIZE(g_szValueNotSet));
/* Get the dimensions of the parent window's client area, and create the list view control. */
GetClientRect(hwndParent, &rcClient);

View File

@ -172,8 +172,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
}
/* Initialize global strings */
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadStringW(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, COUNT_OF(g_pszDefaultValueName));
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
LoadStringW(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, ARRAY_SIZE(g_pszDefaultValueName));
/* Store instance handle in our global variable */
hInst = hInstance;

View File

@ -30,7 +30,7 @@
#define SPLIT_WIDTH 5
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
#define MAX_NEW_KEY_LEN 128

View File

@ -521,7 +521,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
item.mask = TVIF_HANDLE | TVIF_TEXT;
item.hItem = hNewItem;
item.pszText = buf;
item.cchTextMax = COUNT_OF(buf);
item.cchTextMax = ARRAY_SIZE(buf);
if (!TreeView_GetItemW(hwndTV, &item)) continue;
if (lstrcmpW(name, item.pszText) == 0) break;
}