Toolbar icon is not transparent

We've created the IE Toolbar. we show the icon in the toolbar using static control and keeping the image above it.

since this static control is not transparent, so this icon displays some backgroud color (this is the standard color of standard Windows controls).

it is possible to make static control transparent regardless of browser themes.

Project

developed in ATL C ++.

we tried to provide WS_EX_TRANSPARENT as a static control property and when we tried to return null_brush in the OnCtrlColorStatic event but the problem is still not resolved.

0


a source to share


1 answer


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

  • The image must have a "key color" and every pixel of that color in the image will become transparent when displayed. This color should be the color of the first pixel located in the upper left corner of the image. When LoadImage is called with specific flags (detailed below), windows load the image, read the top-left pixel color, and render all pixels in the image the same color as the first one to be hidden (made transparent).

  • When calling LoadImage, the third parameter must be IMAGE_BITMAP OR IMAGE_ICON, depending on which GDI functions you are using to display the image (icon functions or bitmap functions). Also the last flag must contain LR_LOADTRANSPARENT in order to use the color keyboard correctly.

  • After dynamically loading the image as described above, you will have a handle to that resource that you can draw dynamically in the static control display context using standard GDI functions such as DrawIconEx if you loaded it with the IMAGE_ICON flag.



Hope it helps.

+1


a source







All Articles