mirror of
https://github.com/reactos/reactos.git
synced 2025-06-16 21:58:31 +00:00
[REACTOS] InitImageList(): Fix error checks
And simplify code a bit.
This commit is contained in:
parent
a120d67d0e
commit
db416e3914
4 changed files with 24 additions and 11 deletions
|
@ -247,8 +247,7 @@ InitImageList(UINT StartResource,
|
||||||
LR_LOADTRANSPARENT);
|
LR_LOADTRANSPARENT);
|
||||||
if (hImage == NULL)
|
if (hImage == NULL)
|
||||||
{
|
{
|
||||||
ImageList_Destroy(himl);
|
ret = -1;
|
||||||
himl = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1056,8 +1056,7 @@ InitImageList(UINT StartResource,
|
||||||
LR_LOADTRANSPARENT);
|
LR_LOADTRANSPARENT);
|
||||||
if (hImage == NULL)
|
if (hImage == NULL)
|
||||||
{
|
{
|
||||||
ImageList_Destroy(himl);
|
ret = -1;
|
||||||
himl = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,11 +374,11 @@ ToolbarInsertSpaceForControl(HWND hWndToolbar,
|
||||||
HIMAGELIST
|
HIMAGELIST
|
||||||
InitImageList(UINT NumImages, UINT StartResource)
|
InitImageList(UINT NumImages, UINT StartResource)
|
||||||
{
|
{
|
||||||
|
UINT EndResource = StartResource + NumImages - 1;
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
HIMAGELIST hImageList;
|
HIMAGELIST hImageList;
|
||||||
UINT i, k;
|
UINT i;
|
||||||
INT Ret;
|
INT Ret = 0;
|
||||||
DBG_UNREFERENCED_LOCAL_VARIABLE(Ret);
|
|
||||||
|
|
||||||
/* Create the toolbar icon image list */
|
/* Create the toolbar icon image list */
|
||||||
hImageList = ImageList_Create(TB_BMP_WIDTH,
|
hImageList = ImageList_Create(TB_BMP_WIDTH,
|
||||||
|
@ -386,11 +386,11 @@ InitImageList(UINT NumImages, UINT StartResource)
|
||||||
ILC_MASK | ILC_COLOR24,
|
ILC_MASK | ILC_COLOR24,
|
||||||
NumImages,
|
NumImages,
|
||||||
0);
|
0);
|
||||||
if (! hImageList)
|
if (hImageList == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Add all icons to the image list */
|
/* Add all icons to the image list */
|
||||||
for (i = StartResource, k = 0; k < NumImages; i++, k++)
|
for (i = StartResource; i <= EndResource; i++)
|
||||||
{
|
{
|
||||||
hBitmap = LoadImage(hInstance,
|
hBitmap = LoadImage(hInstance,
|
||||||
MAKEINTRESOURCE(i),
|
MAKEINTRESOURCE(i),
|
||||||
|
@ -398,12 +398,26 @@ InitImageList(UINT NumImages, UINT StartResource)
|
||||||
TB_BMP_WIDTH,
|
TB_BMP_WIDTH,
|
||||||
TB_BMP_HEIGHT,
|
TB_BMP_HEIGHT,
|
||||||
LR_LOADTRANSPARENT);
|
LR_LOADTRANSPARENT);
|
||||||
|
if (hBitmap == NULL)
|
||||||
|
{
|
||||||
|
Ret = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Ret = ImageList_AddMasked(hImageList,
|
Ret = ImageList_AddMasked(hImageList,
|
||||||
hBitmap,
|
hBitmap,
|
||||||
RGB(255, 255, 254));
|
RGB(255, 255, 254));
|
||||||
|
|
||||||
DeleteObject(hBitmap);
|
DeleteObject(hBitmap);
|
||||||
|
|
||||||
|
if (Ret == -1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ret == -1)
|
||||||
|
{
|
||||||
|
ImageList_Destroy(hImageList);
|
||||||
|
hImageList = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hImageList;
|
return hImageList;
|
||||||
|
|
|
@ -249,10 +249,11 @@ InitImageList(UINT StartResource,
|
||||||
|
|
||||||
Ret = ImageList_AddIcon(hImageList,
|
Ret = ImageList_AddIcon(hImageList,
|
||||||
hIcon);
|
hIcon);
|
||||||
if (Ret == -1)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
DestroyIcon(hIcon);
|
DestroyIcon(hIcon);
|
||||||
|
|
||||||
|
if (Ret == -1)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hImageList;
|
return hImageList;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue