Click to See Complete Forum and Search --> : Question about STATIC control and HICON


Ali Imran
July 16th, 2006, 10:47 AM
I have few questions regarding static control naD HICON

1. I have an icon loaded and its handle is in a variable of type HICON, now how do I change its size (it is default 32 x 32 as original) ? I mean I want to resize it to say 16 x 16. So that when I display it on a static conrol it shows up 16 x 16.

or

2. Is there any style for a static control we can set while creating it, so that it resizes the icon (to exact width and height of itself) being displayed on it.

3. WS_EX_TRANSPARENT extended style not working on a static control, how to set the background of a static control to transparent ?

4. Can I simply type cast this way to convert an HBITMAP to HICON ?
HICON ic = (HICON) v_hBitMap_handle;


NOTE : keeping in mind that the static being discussed above is being used to display an icon on it.


Any help is highly appreciated.


stay well...

Vitucho
July 16th, 2006, 04:52 PM
if you wanna show some image asociated with a static control you can try to do is static control with the SS_BITMAP or if you want a icon put SS_ICON.

To trully "link" the icon or bitmap in the static control you, obviosly must load it...there guess there are diferent ways....

1.i know for sure the "static" way that consist on linking the image and static control in the resource file.

For that you must (inside de XXX.rc):
"MyBitmap" BITMAP <path>
"MyIcon" ICON <path>

CONTROL "MyBitmap", -1, "static", SS_BITMAP | WS_CHILD | WS_VISIBLE, 128, 22, 18, 15
CONTROL "MyIcon", -1, "static", SS_ICON | WS_CHILD | WS_VISIBLE, 188, 47, 20, 20

NOTE THIS: In the field _text_ of the static control it goes the ID of the Bitmap or ICON to be loaded.

That's the simplest way.

2.Other way it's to use the STM_SETIMAGE to set the static control to display and image.
In that case the static must have the flag SS_BITMAP.

3. More ways....problably =D.

Lucks! I hope that helps!

Ali Imran
July 17th, 2006, 04:32 AM
NOTE : the icon is already loaded, I have successfully displayed it on static. And am in no way using resources, since they are not part of requirement.

Well thanks for reply, but

1. I don't see any text about resizing an already loaded icon or bitmap.

2. If icon is casted to HBITMAP and set using SS_BITMAP, will it resize as per resizing of the static ?

3. Transparency ?

4. Type cast ?

regards