I have a layered window (using SetLayeredWindowAttributes). If I set the alpha on the whole window to 128 and draw black rectangles on it, it works as expected (black rectangles that show through at about 50% opacity).
If, however, I set the aplha on the whole window (when I call SetLayeredWindowAttributes to 255) and then draw black rectangles with a brush that is set to 50%, they black rectangles are purely solid, no translucency whatsoever.
I was under the impression that once I had a layered window in this fashion that I could draw into it with varying levels of per-pixel alpha, so that these two would draw two levels of opacity:
User32.SetLayeredWindowAttributes(this.Handle, (uint) TransparentColorKey.ToArgb(), 255, User32.LWA_ALPHA | User32.LWA_COLORKEY);
e.Graphics.FillRectangle( new SolidBrush(Color.FromArgb(200, 40, 40, 40)), myRect);
e.Graphics.FillRectangle( new SolidBrush(Color.FromArgb( 25, 40, 40, 40)), myRect);
BUT both those rectangles have the same level of opacity (I'd expect one at 200, one at 25). I have control of the opacity ONLY for the entire window as a whole (the 255 in the SetLayeredWindowAttributes).
What am I missing here so that I can draw different elements, even just rectangles, at varying levels of alpha translucency?
BTW, I want SetLayeredWindowAttributes (rather than UpdateLayeredWindow) as I'm doing active drawing into it with device contexts. The latter approach requires a bitmap drawn up and provided in one shot. Thanks! Dave