Search code examples
winapibitmapimagelist

create image list from resource file - win32


I have in .rc file several images, for example:

IDB_COPY BITMAP "copy.bmp"
IDB_CUT BITMAP "cut.bmp"
IDB_PASTE BITMAP "paste.bmp"

And I want to load them all into ImageList.
if I will write

HIMAGELIST hImageList = ImageList_LoadBitmap(hInstance, MAKEINTRESOURCEW(IDB_COPY), 16, 0, RGB(255, 0, 255));

it load only the first bitmap, how do I load them all?


Solution

  • this code make it:

    HIMAGELIST hImageList = ImageList_LoadBitmap(hInstance, MAKEINTRESOURCEW(IDB_CUT), 16, 0, RGB(255, 0, 255));
    
    ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COPY)), NULL);
    ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PASTE)), NULL);