UXTHEME_LoadImage(): Set default image count to 1 to avoid division by

zero in case image count property is not given. Properly support 0
state IDs.
This commit is contained in:
Frank Richter 2005-07-05 14:05:35 +00:00 committed by Alexandre Julliard
parent abb11f30cd
commit 4d4c0a2da9
1 changed files with 3 additions and 3 deletions

View File

@ -190,7 +190,7 @@ static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iState
HBITMAP *hBmp, RECT *bmpRect)
{
int imagelayout = IL_VERTICAL;
int imagecount = 0;
int imagecount = 1;
BITMAP bmp;
WCHAR szPath[MAX_PATH];
PTHEME_PROPERTY tp = UXTHEME_SelectImage(hTheme, hdc, iPartId, iStateId, pRect, glyph);
@ -213,12 +213,12 @@ static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iState
int height = bmp.bmHeight/imagecount;
bmpRect->left = 0;
bmpRect->right = bmp.bmWidth;
bmpRect->top = (min(imagecount, iStateId)-1) * height;
bmpRect->top = (max(min(imagecount, iStateId), 1)-1) * height;
bmpRect->bottom = bmpRect->top + height;
}
else {
int width = bmp.bmWidth/imagecount;
bmpRect->left = (min(imagecount, iStateId)-1) * width;
bmpRect->left = (max(min(imagecount, iStateId), 1)-1) * width;
bmpRect->right = bmpRect->left + width;
bmpRect->top = 0;
bmpRect->bottom = bmp.bmHeight;