views:

329

answers:

1

Hi all,

I am trying to create a custom control that displays a bitmap with per-pixel alphablend (as some of you already know for other questions).

Right now I am using a custom control in the resource editor and I attach it to a class derived from CWnd. When I register my custom class I set the hbrBackground of the WNDCLASS structe to NULL_BRUSH to achive the transparency of the control.

In the OnPaint of the control I use AlphaBlend to paint the per-pixel alpha blend bitmap.

This works quite well but I have this two problems:

  • I want to change the displayed bitmap when the mouse is over the control. As the control is transparent, the areas that one bitmap that are not overlapped by the other bitmap are not erased. How can I erase the background when the image is changed?

  • The second problem is related with two overlapping controls. My control is painted over other control that has a gradient (in fact is inside other control). The problem is that if I put my control before in the z-order the other controls overlap my control and mine is not displayed. If I put the other control before in the z-order I can not get the mouse message in my control.

Maybe I am doing something wrong or I am wrong in how I am trying to implement my control. Any kind of help would be appreciated.

Thanks,

Javier

A: 

I'll take a chance. :-)

This should give you all you need to accomplish what I think you want.

General Solution for Transparent Controls

As far as Z-order issues, the z-order does not affect message priority. You'll need to post some code so we can determine what is happening there.

JustBoo