Below is some introductory information from
MSDN
Layered
Windows
Windows
2000 introduces a new extended window style bit: WS_EX_LAYERED
. When used
properly, it can significantly improve performance and visual effects for a
window that has a complex shape, animates, or wishes to use alpha-blending
effects. The full implementation of layered windows was publicly available for
the first time in Windows 2000 Beta 3.
Windows
appear as rectangles on the screen clipped by other windows. For a window in an
application to look like a circle, it's not enough for the application to simply
paint a window as a circle; the system will continue to hit test this window as
a rectangle and windows underneath this window will still be clipped by the
window's rectangle. So, the window will look and behave like a gray rectangle
with a circle in the middle.
Some
applications might take a snapshot of the visual bits underneath the window
before it was actually shown and later compose those bits with the window bits.
This approach doesn't quite work in a multiprocess, multitasking environment,
because other windows can paint underneath this window. The application has no
way of knowing when such painting occurs or how to somehow retrieve the newly
painted bits underneath.
Using
Layered Windows
For
any layering to take place, the WS_EX_LAYERED
bit needs to be set, either at
window creation time or by calling SetWindowLong
with GWL_EXSTYLE
. Next, the developer has a choice: Use the existing Microsoft
Win32� painting paradigm by responding to WM_PAINT
and/or other paint messages,
or make use of a more powerful layering API, UpdateLayeredWindow
.
To
use UpdateLayeredWindow
, the visual
bits for a layered window have to be rendered into a compatible bitmap. Then,
via a compatible GDI Device Context, the bitmap is provided to the UpdateLayeredWindow
API, along with the desired color-key and alpha-blend information. The bitmap
can also contain per-pixel alpha information.
Note
that when using UpdateLayeredWindow
the application doesn't need to respond to WM_PAINT
or other painting messages,
because it has already provided the visual representation for the window and the
system will take care of storing that image, composing it, and rendering it on
the screen. UpdateLayeredWindow
is
quite powerful, but it often requires modifying the way an existing Win32
application draws.
The
second way to use layered windows is to continue using the Win32 painting
paradigm, but allowing the system to redirect all the drawing for the layered
window and its children into an off-screen bitmap. This can be done by calling SetLayeredWindowAttributes
with the desired constant alpha value and/or the color-key. Once the API has
been called, the system will start redirecting all drawing by the window and
automatically apply the specified effects.
Hit
Testing
Hit
testing of a layered window is based on the shape and transparency of the
window. This means that the areas of the window that are color-keyed or whose
alpha value is zero will let the mouse messages through.
If the
layered window has the WS_EX_TRANSPARENT
extended window style, the shape of the
layered window will be ignored and the mouse events will be passed to the other
windows underneath the layered window
Screen
Mate
This
Screen Mate is a simple program using the new feature Layered Windows. We can
develop very easy and more efficient Screen Mates using this new feature than
Windows Regions. I am only a student in VC++ .Anybody wants
any modification in this program i am ready to accept the modifications .
Conclusion
Layered
windows present an efficient way to add transparency and translucency to
top-level windows. They enable developers to easily incorporate modern UI and
cool transition effects into new as well as already existing applications.