hi, :bg
i have an icon file that has many icon formats in it.
let say that the icon file has 4 icon formats in it (16*16,32*32,48*48,128*128),the question is how can i load a specific icon format?
i have attached a demo icon file.
[attachment deleted by admin]
It depends on how do you load these resources; there are three different approaches:
First, simplest:
push hModule ;DWORD, SDK type is HMODULE, that what you got after a call to GetModuleHandle(NULL)
push IconOrdinal ;DWORD, LOWORD contains ordinal
push IMAGE_ICON ;DWORD, one of { IMAGE_BITMAP, IMAGE_CURSOR, IMAGE_ICON }
push cxDesired ;Icon that will be loaded has this X pixels
push cyDesired ;Icon that will be loaded has this Y pixels
push fuLoad ;DWORD, usually only LR_DEFAULTCOLOR
call [user32!LoadImage]
test eax, eax
jz L_exit ;Failed, you must get non-zero value which you'll free later with DestroyIcon() call
mov [hIcon], eax
....
Second, find your resource and lock it, getting pointer to it:
FindResourceEx,
SizeofResource,
LoadResource,
LockResource (after this you'll get direct mem ptr to the resource)
Third, you are obviously not using icon resource in order to make your exe more colorful :) probably you're loading it to stick it to a button or something;
if this is the case, consider using device indenpendent bitmap (DIB) or image list (even better, you can do some animation as well :)
HTH,
^VlaaD^
Just use LoadImage, if you specify cxDesired and cyDesired you can load any one you want.
thank you a lot