From 9a03000e5e5d9efae71c9341782722d1fbe0a7f0 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Mon, 29 Aug 2005 10:15:59 +0000 Subject: [PATCH] Take a common computation out of two if-branches in UXTHEME_LoadImage(). --- dlls/uxtheme/draw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c index 9961aca94cc..6fcab5fa20a 100644 --- a/dlls/uxtheme/draw.c +++ b/dlls/uxtheme/draw.c @@ -210,6 +210,7 @@ static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iState { int imagelayout = IL_HORIZONTAL; int imagecount = 1; + int imagenum; BITMAP bmp; WCHAR szPath[MAX_PATH]; BOOL hasAlpha; @@ -228,17 +229,18 @@ static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iState GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_IMAGELAYOUT, &imagelayout); GetThemeInt(hTheme, iPartId, iStateId, TMT_IMAGECOUNT, &imagecount); + imagenum = max (min (imagecount, iStateId), 1) - 1; GetObjectW(*hBmp, sizeof(bmp), &bmp); if(imagelayout == IL_VERTICAL) { int height = bmp.bmHeight/imagecount; bmpRect->left = 0; bmpRect->right = bmp.bmWidth; - bmpRect->top = (max(min(imagecount, iStateId), 1)-1) * height; + bmpRect->top = imagenum * height; bmpRect->bottom = bmpRect->top + height; } else { int width = bmp.bmWidth/imagecount; - bmpRect->left = (max(min(imagecount, iStateId), 1)-1) * width; + bmpRect->left = imagenum * width; bmpRect->right = bmpRect->left + width; bmpRect->top = 0; bmpRect->bottom = bmp.bmHeight;