Commit e8411d22 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

user32: Use the available ARRAY_SIZE() macro.

parent 6e7f28d9
......@@ -150,7 +150,7 @@ static BOOL is_comctl32_class( const WCHAR *name )
{'t','o','o','l','t','i','p','s','_','c','l','a','s','s','3','2',0},
};
int min = 0, max = (sizeof(classesW) / sizeof(classesW[0])) - 1;
int min = 0, max = ARRAY_SIZE( classesW ) - 1;
while (min <= max)
{
......@@ -171,7 +171,7 @@ static BOOL is_builtin_class( const WCHAR *name )
{'S','c','r','o','l','l','b','a','r',0},
};
int min = 0, max = (sizeof(classesW) / sizeof(classesW[0])) - 1;
int min = 0, max = ARRAY_SIZE( classesW ) - 1;
while (min <= max)
{
......@@ -473,7 +473,7 @@ static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE
strcpyW( classPtr->name, name );
classPtr->basename += basename_offset;
}
else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, sizeof(classPtr->name)/sizeof(WCHAR) );
else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, ARRAY_SIZE( classPtr->name ));
SERVER_START_REQ( create_class )
{
......@@ -1125,7 +1125,7 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
if (!set_server_info( hwnd, offset, newval, size )) break;
retval = class->atomName;
class->atomName = newval;
GlobalGetAtomNameW( newval, class->name, sizeof(class->name)/sizeof(WCHAR) );
GlobalGetAtomNameW( newval, class->name, ARRAY_SIZE( class->name ));
break;
case GCL_CBCLSEXTRA: /* cannot change this one */
SetLastError( ERROR_INVALID_PARAMETER );
......@@ -1166,7 +1166,7 @@ INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
DWORD len;
if (count <= 0) return 0;
if (!GetClassNameW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
if (!GetClassNameW( hwnd, tmpbuf, ARRAY_SIZE( tmpbuf ))) return 0;
RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
buffer[len] = 0;
return len;
......@@ -1299,7 +1299,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
if (!IS_INTRESOURCE(name))
{
WCHAR nameW[MAX_ATOM_LEN + 1];
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ))
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW )))
return FALSE;
classPtr = CLASS_FindClass( nameW, hInstance );
}
......
......@@ -960,7 +960,7 @@ static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM wParam )
{
dlgCode = SendMessageW( hwndControl, WM_GETDLGCODE, 0, 0 );
if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
GetWindowTextW( hwndControl, buffer, ARRAY_SIZE( buffer )))
{
/* find the accelerator key */
LPWSTR p = buffer - 2;
......@@ -1868,7 +1868,7 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
{
WCHAR temp[MAX_PATH];
GetCurrentDirectoryW( sizeof(temp)/sizeof(WCHAR), temp );
GetCurrentDirectoryW( ARRAY_SIZE( temp ), temp );
CharLowerW( temp );
/* Can't use PostMessage() here, because the string is on the stack */
SetDlgItemTextW( hDlg, idStatic, temp );
......
......@@ -286,8 +286,8 @@ static UINT ICO_ExtractIconExW(
TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL);
if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0])))
dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, ARRAY_SIZE(szExePath), szExePath, NULL);
if ((dwSearchReturn == 0) || (dwSearchReturn > ARRAY_SIZE(szExePath)))
{
WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName));
return -1;
......
......@@ -437,7 +437,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
if (visible == MDI_MOREWINDOWSLIMIT)
{
LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, sizeof(buf)/sizeof(WCHAR));
LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, ARRAY_SIZE(buf));
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
break;
}
......@@ -453,7 +453,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
buf[0] = '&';
buf[1] = '0' + visible;
buf[2] = ' ';
InternalGetWindowText(ci->child[i], buf + 3, sizeof(buf)/sizeof(WCHAR) - 3);
InternalGetWindowText(ci->child[i], buf + 3, ARRAY_SIZE(buf) - 3);
TRACE("Adding %p, id %u %s\n", ci->child[i], id, debugstr_w(buf));
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
......@@ -979,7 +979,7 @@ static void MDI_UpdateFrameText( HWND frame, HWND hClient, BOOL repaint, LPCWSTR
if (!lpTitle && !ci->frameTitle) /* first time around, get title from the frame window */
{
GetWindowTextW( frame, lpBuffer, sizeof(lpBuffer)/sizeof(WCHAR) );
GetWindowTextW( frame, lpBuffer, ARRAY_SIZE( lpBuffer ));
lpTitle = lpBuffer;
}
......@@ -1910,7 +1910,7 @@ static INT_PTR WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wPara
{
WCHAR buffer[MDI_MAXTITLELENGTH];
if (!InternalGetWindowText( ci->child[i], buffer, sizeof(buffer)/sizeof(WCHAR) ))
if (!InternalGetWindowText(ci->child[i], buffer, ARRAY_SIZE(buffer)))
continue;
SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM)buffer );
SendMessageW(hListBox, LB_SETITEMDATA, i, (LPARAM)ci->child[i] );
......
......@@ -5510,7 +5510,7 @@ INT WINAPI TranslateAcceleratorW( HWND hWnd, HACCEL hAccel, LPMSG msg )
hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam);
if (!(count = CopyAcceleratorTableW( hAccel, NULL, 0 ))) return 0;
if (count > sizeof(data)/sizeof(data[0]))
if (count > ARRAY_SIZE( data ))
{
if (!(ptr = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ptr) ))) return 0;
}
......
......@@ -2312,7 +2312,7 @@ static BOOL process_rawinput_message( MSG *msg, const struct hardware_msg_data *
rawinput->data.mouse.usFlags = MOUSE_MOVE_RELATIVE;
rawinput->data.mouse.u.s.usButtonFlags = 0;
rawinput->data.mouse.u.s.usButtonData = 0;
for (i = 1; i < sizeof(button_flags) / sizeof(*button_flags); ++i)
for (i = 1; i < ARRAY_SIZE(button_flags); ++i)
{
if (msg_data->flags & (1 << i))
rawinput->data.mouse.u.s.usButtonFlags |= button_flags[i];
......@@ -3902,7 +3902,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg )
}
GetKeyboardState( state );
len = ToUnicode(msg->wParam, HIWORD(msg->lParam), state, wp, sizeof(wp)/sizeof(WCHAR), 0);
len = ToUnicode(msg->wParam, HIWORD(msg->lParam), state, wp, ARRAY_SIZE(wp), 0);
if (len == -1)
{
message = (msg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
......
......@@ -294,7 +294,7 @@ static void MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb)
/* Position the buttons */
bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2;
for (buttons = i = 0; i < (sizeof(buttonOrder) / sizeof(buttonOrder[0])); i++) {
for (buttons = i = 0; i < ARRAY_SIZE(buttonOrder); i++) {
/* Convert the button order to ID* value to order for the buttons */
hItem = GetDlgItem(hwnd, buttonOrder[i]);
......
......@@ -343,7 +343,7 @@ BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
if (!str)
{
if (!GetWindowTextW( hwnd, text, sizeof(text)/sizeof(WCHAR) )) text[0] = 0;
if (!GetWindowTextW( hwnd, text, ARRAY_SIZE( text ))) text[0] = 0;
str = text;
}
rc.left += 2;
......@@ -953,7 +953,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, DWORD style,
}
}
if (GetWindowTextW( hwnd, buffer, sizeof(buffer)/sizeof(WCHAR) ))
if (GetWindowTextW( hwnd, buffer, ARRAY_SIZE( buffer )))
{
NONCLIENTMETRICSW nclm;
HFONT hFont, hOldFont;
......
......@@ -2127,7 +2127,7 @@ const char *SPY_GetClassLongOffsetName( INT offset )
{
INT index;
if (offset < 0 && offset % 2 == 0 && ((index = -(offset + 8) / 2) <
sizeof(ClassLongOffsetNames) / sizeof(*ClassLongOffsetNames)))
ARRAY_SIZE(ClassLongOffsetNames)))
{
return ClassLongOffsetNames[index];
}
......@@ -2148,7 +2148,7 @@ static void SPY_GetClassName( SPY_INSTANCE *sp_e )
strcpyW(sp_e->wnd_class, WC_PROPSHEETW);
}
else {
GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, sizeof(sp_e->wnd_class)/sizeof(WCHAR));
GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, ARRAY_SIZE(sp_e->wnd_class));
}
}
......@@ -2223,12 +2223,12 @@ static void SPY_GetWndName( SPY_INSTANCE *sp_e )
SPY_GetClassName( sp_e );
len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, sizeof(sp_e->wnd_name)/sizeof(WCHAR));
len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, ARRAY_SIZE(sp_e->wnd_name));
if(!len) /* get class name */
{
LPWSTR dst = sp_e->wnd_name;
LPWSTR src = sp_e->wnd_class;
int n = sizeof(sp_e->wnd_name)/sizeof(WCHAR) - 3;
int n = ARRAY_SIZE(sp_e->wnd_name) - 3;
*dst++ = '{';
while ((n-- > 0) && *src) *dst++ = *src++;
*dst++ = '}';
......@@ -2537,8 +2537,7 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter)
if (pnmh->code == NM_CUSTOMDRAW) {
/* save and restore error code over the next call */
save_error = GetLastError();
GetClassNameW(pnmh->hwndFrom, from_class,
sizeof(from_class)/sizeof(WCHAR));
GetClassNameW(pnmh->hwndFrom, from_class, ARRAY_SIZE(from_class));
SetLastError(save_error);
if (strcmpW(TOOLBARCLASSNAMEW, from_class) == 0)
dumplen = sizeof(NMTBCUSTOMDRAW)-sizeof(NMHDR);
......
......@@ -1383,7 +1383,7 @@ void SYSPARAMS_Init(void)
if (volatile_base_key && dispos == REG_CREATED_NEW_KEY) /* first process, initialize entries */
{
for (i = 0; i < sizeof(default_entries)/sizeof(default_entries[0]); i++)
for (i = 0; i < ARRAY_SIZE( default_entries ); i++)
default_entries[i]->hdr.init( default_entries[i] );
}
}
......@@ -2251,9 +2251,8 @@ BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
{
WCHAR buffer[256];
if (pvParam)
if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer,
sizeof(buffer)/sizeof(WCHAR) ))
buffer[sizeof(buffer)/sizeof(WCHAR)-1] = 0;
if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer, ARRAY_SIZE( buffer )))
buffer[ARRAY_SIZE(buffer)-1] = 0;
ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni );
break;
}
......
......@@ -970,7 +970,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
do
{
len = sizeof(line)/sizeof(line[0]);
len = ARRAY_SIZE(line);
if (invert_y)
last_line = !(flags & DT_NOCLIP) && y - ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) < rect->bottom;
else
......
......@@ -1748,7 +1748,7 @@ HWND WINAPI DECLSPEC_HOTPATCH CreateWindowExA( DWORD exStyle, LPCSTR className,
if (!IS_INTRESOURCE(className))
{
WCHAR bufferW[256];
if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, ARRAY_SIZE( bufferW )))
return 0;
return wow_handlers.create_window( (CREATESTRUCTW *)&cs, bufferW, instance, FALSE );
}
......@@ -2024,7 +2024,7 @@ HWND WINAPI FindWindowExA( HWND parent, HWND child, LPCSTR className, LPCSTR tit
if (!IS_INTRESOURCE(className))
{
WCHAR classW[256];
if (MultiByteToWideChar( CP_ACP, 0, className, -1, classW, sizeof(classW)/sizeof(WCHAR) ))
if (MultiByteToWideChar( CP_ACP, 0, className, -1, classW, ARRAY_SIZE( classW )))
hwnd = FindWindowExW( parent, child, classW, titleW );
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment