Domanda

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?

È stato utile?

Soluzione

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);

Altri suggerimenti

If you are using C++11 or above, I recommend using std::map.

map<string,HBITMAP> hbm; // #include <map>
hbm["CUT"]=LoadBitmap(hInstance,MAKEINTRESOURCEW(IDB_CUT));
// ...
// or
map<int,HBITMAP> hbm1;
hbm1[0]=LoadBitmap(hInstance,MAKEINTRESOURCEW(IDB_CUT));
//...

I think it is more flexible and convenient as images with different sizes can also be accepted.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top