Abstract
CLayeredWindowHelperST
is a wrapper class of all required APIs to add support for transparent (layered)
windows to your applications. This is a scalable class. If running under Windows 2000/XP your windows
will have the selected transparent effect, while if running under Windows 9x/ME/NT will run error-less.
How to integrate CLayeredWindowHelperST in your application
In your project include the following files:
- LayeredWindowHelperST.h
- LayeredWindowHelperST.cpp
Create a instance of
CLayeredWindowHelperST
. This class encapsulates all the required APIs to support
transparent windows and to run error-less if running under a old Windows version that doesn't support this feature.
You need only one instance, so this can be global to the application.
CLayeredWindowHelperST G_Layered;
Modify the style of your window, then set the transparency effect. For dialog-based applications, in your
OnInitDialog
:
CDialog::OnInitDialog();
G_Layered.AddLayeredStyle(m_hWnd);
G_Layered.SetTransparentPercentage(m_hWnd, 70);
-or-
G_Layered.SetLayeredWindowAttributes(m_hWnd, 0, 210, LWA_ALPHA);
Class methods
AddLayeredStyle
Adds the WS_EX_LAYERED
style to the specified window.
This style is required to have a transparent effect.
LONG AddLayeredStyle(HWND hWnd)
SetLayeredWindowAttributes
Sets the opacity and transparency color key of a transparent (layered) window.
BOOL SetLayeredWindowAttributes(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
SetTransparentPercentage
Sets the percentage of opacity or transparency of a layered window.
BOOL SetTransparentPercentage(HWND hWnd, BYTE byPercentage)
GetVersionI
Returns the class version as a short value.
static short GetVersionI()
GetVersionC
Returns the class version as a string value.
static LPCTSTR GetVersionC()
Remarks
To compile CLayeredWindowHelperST
you need the Platform SDK (August 2001 or newer). This is not
mandatory because at compile-time, if not found, it will be emulated. At run-time you don't need any
additional SDK or libraries installed.
History
- v1.0 (17/January/2002)
First release
Disclaimer
THE SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED.
NO REPONSIBILITIES FOR POSSIBLE DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN.
THE USER MUST ASSUME THE ENTIRE RISK OF USING THIS SOFTWARE.