I am trying to create a color icon dynamically in memory. I have not been able to get CreateIcon() to work. Would anyone have source or a link to help illustrate. Thanks.
Posted on 2001-09-13 10:31:56 by metalman

Your making some sorta ICON generator? Or are you trying to get the ICON pic from memory and then painting it somewhere on your window? (The latter i can help you with)

Posted on 2001-09-13 17:01:56 by NaN
I am trying to create a color icon dynamically (not loaded from the exe or from a .ico file) instead of LoadIcon(). I got monochrome to work, but could not get my XORbitmask parm to be accepted by CreateIcon(). I am now trying to decypher the in memory resource format to use CreateIconFromResource(). I am open to other suggestions.
Posted on 2001-09-13 19:07:43 by metalman
You got me curious, so i tinkered for about and hour with Icons..

I found that CreateIcon() is mainly suited for Black and White images.. as i got it to work with this.. It did sugest a refernce to BITMAPS if i wanted to make a color one, but doesnt say _how_.

I also tried CreateIconIndirect( addr INCOINFO ), I found this method very easy to make an icon.


invoke LoadBitmap, hInstance, 700
mov hBitmap, eax


mov ii.fIcon, TRUE
mov eax, hBitmap
mov ii.bmMask, eax ; also works with -1
mov ii.bmColor, eax ; must for color icons..
invoke CreateIconIndirect, addr ii
mov hIcon, eax


invoke DrawIconEx, ps.hdc, 50, 50, hIcon, 20, 20, NULL, NULL, DI_NORMAL


invoke DestroyIcon, hIcon
invoke DeleteObject, hBitmap

I realize this isnt as direct as CreateIcon() is, hence the name *Indirect*. But you could most likely get what ever you want done with this one faster. For instance you would create a separate DC, and then Create a Bitmap and select it to the dc. Then take stored information (in any cryptic format you choose), decifer it and plot pixels to this bitmap. Then lastly use CreateIconIndirect to create an icon from the bitmap you just drew.

Kind of a long way around.. but its the only solution i can make sence outa, as your right, the xorMask is hard to understand.

Hope This Helps...
Posted on 2001-09-14 01:29:09 by NaN
With your help, I also got CreateIconIndirect() to work.
Posted on 2001-09-14 18:37:55 by metalman