tags:

views:

165

answers:

1

We have created an IE toolbar. we are displaying an icon on toolbar by using a static control and keeping image over it.

as this static control is not transparent so this icon is displaying some backgroud color(this is default color of windows common controls).

is it possible to make the static control as transparent irrespective of browser themes.

project is developed in ATL C++.

we tried giving WS_EX_TRANSPARENT as property of static control and when we tried returning null_brush in OnCtrlColorStatic event, but still problem is not resolved.

A: 

Well, I don't know much about ATL, but in standard Windows API you would use LoadImage function to load up the image. Here are some tips for getting images with transparent portions (of transparent background):

  1. The image must have a "key color", and every pixel of that color in the image will become transparent at display time. That color must be the color of the first pixel, located at the top left of the image. Upon calling LoadImage with certain flags (detailed bellow), windows will load the image, read the top left pixel color and make all the pixels in the image that have the same color as the first one to be hidden (they are made transparent).

  2. When you call LoadImage, the third parameter must be IMAGE_BITMAP OR IMAGE_ICON, and that depends on which GDI functions do you use to display the image (icon functions or bitmap functions). Also the last flag must contain LR_LOADTRANSPARENT in order to properly use the color keying.

  3. After dynamically loading the image as described above, you will have a handle to this resource, that you can dynamically draw on your static control's display context using standard GDI functions, like DrawIconEx if you have loaded it using IMAGE_ICON flag.

Hope it helps.

Mihai Cozma
Now I saw that the question is very old, but might help other people searching for help on the web.
Mihai Cozma