mirror of
https://github.com/reactos/reactos.git
synced 2025-06-16 18:18:32 +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);
|
||||
if (hImage == NULL)
|
||||
{
|
||||
ImageList_Destroy(himl);
|
||||
himl = NULL;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1056,8 +1056,7 @@ InitImageList(UINT StartResource,
|
|||
LR_LOADTRANSPARENT);
|
||||
if (hImage == NULL)
|
||||
{
|
||||
ImageList_Destroy(himl);
|
||||
himl = NULL;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -374,11 +374,11 @@ ToolbarInsertSpaceForControl(HWND hWndToolbar,
|
|||
HIMAGELIST
|
||||
InitImageList(UINT NumImages, UINT StartResource)
|
||||
{
|
||||
UINT EndResource = StartResource + NumImages - 1;
|
||||
HBITMAP hBitmap;
|
||||
HIMAGELIST hImageList;
|
||||
UINT i, k;
|
||||
INT Ret;
|
||||
DBG_UNREFERENCED_LOCAL_VARIABLE(Ret);
|
||||
UINT i;
|
||||
INT Ret = 0;
|
||||
|
||||
/* Create the toolbar icon image list */
|
||||
hImageList = ImageList_Create(TB_BMP_WIDTH,
|
||||
|
@ -386,11 +386,11 @@ InitImageList(UINT NumImages, UINT StartResource)
|
|||
ILC_MASK | ILC_COLOR24,
|
||||
NumImages,
|
||||
0);
|
||||
if (! hImageList)
|
||||
if (hImageList == NULL)
|
||||
return NULL;
|
||||
|
||||
/* 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,
|
||||
MAKEINTRESOURCE(i),
|
||||
|
@ -398,12 +398,26 @@ InitImageList(UINT NumImages, UINT StartResource)
|
|||
TB_BMP_WIDTH,
|
||||
TB_BMP_HEIGHT,
|
||||
LR_LOADTRANSPARENT);
|
||||
if (hBitmap == NULL)
|
||||
{
|
||||
Ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
Ret = ImageList_AddMasked(hImageList,
|
||||
hBitmap,
|
||||
RGB(255, 255, 254));
|
||||
|
||||
DeleteObject(hBitmap);
|
||||
|
||||
if (Ret == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (Ret == -1)
|
||||
{
|
||||
ImageList_Destroy(hImageList);
|
||||
hImageList = NULL;
|
||||
}
|
||||
|
||||
return hImageList;
|
||||
|
|
|
@ -249,10 +249,11 @@ InitImageList(UINT StartResource,
|
|||
|
||||
Ret = ImageList_AddIcon(hImageList,
|
||||
hIcon);
|
||||
if (Ret == -1)
|
||||
goto fail;
|
||||
|
||||
DestroyIcon(hIcon);
|
||||
|
||||
if (Ret == -1)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return hImageList;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue