This project is read-only.

Using Layered Windows (Z-Pixel's Form Class)

If you have ever used a program such a ObjectDock, or even the Vista Sidebar, you have probably noticed the cool alpha blending windows that they have. These are not new to Vista at all. In fact, they go back to Windows 2000, with the advent of "layered windows". These are special windows that are handled specially by the Windows rendering engine. Instead of being drawn into a region of the screen, they are composited on top of other windows automatically. There are no WM_PAINT messages for layered windows. Instead, you simply tell Windows to use any bitmap, specifically one with an alpha channel.

Previously, it was hard to use such layered windows in .NET because of all of the interop required. However, Z-Pixel makes it easy with the ZPixel.Form class. Inheriting the System.Windows.Forms.Form class, ZPixel.Form provides an "Image" property that you can set to any alpha-blended bitmap. It will also attempt to draw all child controls onto itself using the System.Windows.Forms.Control.DrawToBitmap method.

To use layered windows in your own program, simply create a class that inherits ZPixel.Form. All of the normal form properties can be used such as TopMost, Icon, and Text. Then set the Image property and display the form as you would any normal form, using the Show method.

Another capability of layered windows is the ability to make a form "click-through". This means that the form will ignore all mouse activity and instead will pass it to windows underneath it. To use this functionality with your own forms, call the ZPixel.Form constructor's overload that uses a boolean parameter. Setting this to "true" will cause the form to be "click-through".

Last edited Sep 24, 2007 at 11:04 PM by zhuman, version 1


No comments yet.