diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c index d07d0753da5..69c53b9ebc3 100644 --- a/dlls/uxtheme/draw.c +++ b/dlls/uxtheme/draw.c @@ -198,8 +198,7 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, HBITMAP hBmp; BOOL hasAlpha; - lstrcpynW(szPath, fileProp->lpValue, - min(fileProp->dwValueLen+1, sizeof(szPath)/sizeof(szPath[0]))); + lstrcpynW(szPath, fileProp->lpValue, min(fileProp->dwValueLen+1, ARRAY_SIZE(szPath))); hBmp = MSSTYLES_LoadBitmap(hTheme, szPath, &hasAlpha); if(!hBmp) continue; @@ -245,7 +244,7 @@ static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iState FIXME("Couldn't determine image for part/state %d/%d, invalid theme?\n", iPartId, iStateId); return E_PROP_ID_UNSUPPORTED; } - lstrcpynW(szPath, tp->lpValue, min(tp->dwValueLen+1, sizeof(szPath)/sizeof(szPath[0]))); + lstrcpynW(szPath, tp->lpValue, min(tp->dwValueLen+1, ARRAY_SIZE(szPath))); *hBmp = MSSTYLES_LoadBitmap(hTheme, szPath, hasImageAlpha); if(!*hBmp) { TRACE("Failed to load bitmap %s\n", debugstr_w(szPath)); diff --git a/dlls/uxtheme/metric.c b/dlls/uxtheme/metric.c index daf17ca35ad..5f6c36f5cf5 100644 --- a/dlls/uxtheme/metric.c +++ b/dlls/uxtheme/metric.c @@ -181,7 +181,7 @@ int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID) }; if(hTheme) { - for(i=0; i= TMT_FIRSTCOLOR && iPropertyId <= TMT_LASTCOLOR) { if (!parse_handle_color_property (&colorState, iPropertyId, @@ -948,7 +948,7 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics) ps = MSSTYLES_AddPartState(cls, iPartId, iStateId); while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) { - lstrcpynW(szPropertyName, lpName, min(dwLen+1, sizeof(szPropertyName)/sizeof(szPropertyName[0]))); + lstrcpynW(szPropertyName, lpName, min(dwLen+1, ARRAY_SIZE(szPropertyName))); if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) { MSSTYLES_AddProperty(ps, iPropertyPrimitive, iPropertyId, lpValue, dwValueLen, isGlobal); } @@ -1014,13 +1014,13 @@ PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList) start = pszClassList; while((end = strchrW(start, ';'))) { len = end-start; - lstrcpynW(szClassName, start, min(len+1, sizeof(szClassName)/sizeof(szClassName[0]))); + lstrcpynW(szClassName, start, min(len+1, ARRAY_SIZE(szClassName))); start = end+1; cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName); if(cls) break; } if(!cls && *start) { - lstrcpynW(szClassName, start, sizeof(szClassName)/sizeof(szClassName[0])); + lstrcpynW(szClassName, start, ARRAY_SIZE(szClassName)); cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName); } if(cls) { @@ -1120,7 +1120,7 @@ HBITMAP MSSTYLES_LoadBitmap (PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha WCHAR szFile[MAX_PATH]; LPWSTR tmp; PTHEME_IMAGE img; - lstrcpynW(szFile, lpFilename, sizeof(szFile)/sizeof(szFile[0])); + lstrcpynW(szFile, lpFilename, ARRAY_SIZE(szFile)); tmp = szFile; do { if(*tmp == '\\') *tmp = '_'; @@ -1273,7 +1273,7 @@ static HRESULT MSSTYLES_GetFont (LPCWSTR lpCur, LPCWSTR lpEnd, pFont->lfHeight = pointSize; pFont->lfWeight = FW_REGULAR; pFont->lfCharSet = DEFAULT_CHARSET; - while(MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, attr, sizeof(attr)/sizeof(attr[0]))) { + while(MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, attr, ARRAY_SIZE(attr))) { if(!lstrcmpiW(szBold, attr)) pFont->lfWeight = FW_BOLD; else if(!lstrcmpiW(szItalic, attr)) pFont->lfItalic = TRUE; else if(!lstrcmpiW(szUnderline, attr)) pFont->lfUnderline = TRUE; diff --git a/dlls/uxtheme/property.c b/dlls/uxtheme/property.c index 9dffbdde87f..0e077aeec46 100644 --- a/dlls/uxtheme/property.c +++ b/dlls/uxtheme/property.c @@ -87,7 +87,7 @@ HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId))) return E_PROP_ID_UNSUPPORTED; - hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0])); + hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) @@ -262,7 +262,7 @@ HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId, case TMT_COLOR: return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal); case TMT_ENUM: - hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0])); + hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index a310d4031d4..19e3c932240 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -1051,7 +1051,7 @@ BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszStat *iPartId = 0; *iStateId = 0; - for(i=0; ipszSelectedColor, sizeof(szCurrentColor)/sizeof(szCurrentColor[0])); - lstrcpynW(szCurrentSize, pt->pszSelectedSize, sizeof(szCurrentSize)/sizeof(szCurrentSize[0])); + lstrcpynW(szCurrentColor, pt->pszSelectedColor, ARRAY_SIZE(szCurrentColor)); + lstrcpynW(szCurrentSize, pt->pszSelectedSize, ARRAY_SIZE(szCurrentSize)); MSSTYLES_SetActiveTheme(pt, FALSE); TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme), @@ -477,9 +477,9 @@ static HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf) return hr; if(tf) { bThemeActive = TRUE; - lstrcpynW(szCurrentTheme, tf->szThemeFile, sizeof(szCurrentTheme)/sizeof(szCurrentTheme[0])); - lstrcpynW(szCurrentColor, tf->pszSelectedColor, sizeof(szCurrentColor)/sizeof(szCurrentColor[0])); - lstrcpynW(szCurrentSize, tf->pszSelectedSize, sizeof(szCurrentSize)/sizeof(szCurrentSize[0])); + lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme)); + lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor)); + lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize)); } else { UXTHEME_RestoreSystemMetrics(); @@ -661,9 +661,9 @@ HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags) if(bThemeActive) { - pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0])); + pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, ARRAY_SIZE(szAppBuff)); /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */ - pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0])); + pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, ARRAY_SIZE(szClassBuff)); if(!pszUseClassList) pszUseClassList = pszClassList; @@ -837,7 +837,7 @@ HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName, /* Try to load from string resources */ hr = E_PROP_ID_UNSUPPORTED; if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) { - for(i=0; ihTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) { hr = S_OK; @@ -1049,9 +1049,9 @@ HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback, && !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) { wsprintfW(szPath, szFormat, szDir, wfd.cFileName, wfd.cFileName); - hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, sizeof(szName)/sizeof(szName[0])); + hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, ARRAY_SIZE(szName)); if(SUCCEEDED(hr)) - hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, sizeof(szTip)/sizeof(szTip[0])); + hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, ARRAY_SIZE(szTip)); if(SUCCEEDED(hr)) { TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData); if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) { @@ -1113,12 +1113,10 @@ HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName, if(!dwColorNum && *tmp) { TRACE("%s\n", debugstr_w(tmp)); lstrcpyW(pszColorNames->szName, tmp); - LoadStringW (pt->hTheme, resourceId, - pszColorNames->szDisplayName, - sizeof (pszColorNames->szDisplayName) / sizeof (WCHAR)); - LoadStringW (pt->hTheme, resourceId+1000, - pszColorNames->szTooltip, - sizeof (pszColorNames->szTooltip) / sizeof (WCHAR)); + LoadStringW(pt->hTheme, resourceId, pszColorNames->szDisplayName, + ARRAY_SIZE(pszColorNames->szDisplayName)); + LoadStringW(pt->hTheme, resourceId+1000, pszColorNames->szTooltip, + ARRAY_SIZE(pszColorNames->szTooltip)); } else hr = E_PROP_ID_UNSUPPORTED; @@ -1173,12 +1171,10 @@ HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName, if(!dwSizeNum && *tmp) { TRACE("%s\n", debugstr_w(tmp)); lstrcpyW(pszSizeNames->szName, tmp); - LoadStringW (pt->hTheme, resourceId, - pszSizeNames->szDisplayName, - sizeof (pszSizeNames->szDisplayName) / sizeof (WCHAR)); - LoadStringW (pt->hTheme, resourceId+1000, - pszSizeNames->szTooltip, - sizeof (pszSizeNames->szTooltip) / sizeof (WCHAR)); + LoadStringW(pt->hTheme, resourceId, pszSizeNames->szDisplayName, + ARRAY_SIZE(pszSizeNames->szDisplayName)); + LoadStringW(pt->hTheme, resourceId+1000, pszSizeNames->szTooltip, + ARRAY_SIZE(pszSizeNames->szTooltip)); } else hr = E_PROP_ID_UNSUPPORTED;