News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

displaying only part of an icon

Started by z4ziggy, December 31, 2006, 03:03:09 PM

Previous topic - Next topic

z4ziggy

Hello people,

I have a bmp which i'm loading using ImageList_LoadImage. the image is a toolbar consisting of 4 rows of images in the following format :

    A   B   C   D   E
0   a1  b1  c1  d1  e1
1   a2  b2  c2  d2  e2
2   a3  b3  c3  d3  e3
3   a4  b4  c4  d4  e4


etc.
each column is for one button bitmap with 4 modes - enabled, mouse_over, clicked, and disabled.
I'm extracting each column as an icon using ImageList_GetIcon and then trying to display the appropriate icon on WM_PAINT using DrawIconEx but i can't find a way to "cut" and display only the appropriate icon-part i need (the 1st part for enabled, 2nd part when the mouse is over the button, etc). What is the way to cut and display the appropriate part of the icon?

Thank you in advance,
z4ziggy

ramguru

You should not make things difficult. Make one row of images:

a1  b1  c1  d1  e1 a2  b2  c2  d2  e2 ...

Specify width, height of each icon, then you'll be able to retrieve image you need by index, split is auto-made...if all images are in one row.

z4ziggy

the problem with that solution is that i will need to change each bmp i have, and since the idea is to use the toolbar bmp from FireFox theme files on-the-fly (my application is a mini-IE with same toolbar icons...) its not such a great solution. i know there is a way to display only part of the icon on WM_PAINT, i just can't seem to remember it...

Relvinian

z4ziggy,

When you draw using BltBlt, specify the offset (both x and y) of the source image you want drawn. Take a look at the API for BltBlt to see what params you need for the source offset.

Relvinian