This class is derived from the MFC
CDialog. It supports the following features
- If running on Windows 2000 or Windows XP, make any one color transparent so
that you can see through regions of the dialog
- If running on Windows 2000 or Windows XP, make the whole dialog translucent
- Adding a bitmap to the back ground. The bitmap can be a resource, a BMP
file, or a
- Set style for background : Tile, Center, Stretch, resize dialog to the
size of the bitmap
- Can enable/disable moving the dialog by clicking anywhere in it
Previous to Windows 2000 creating skinned dialogs were a bit difficult. You
needed to write functions that could parse through the back ground image and
CRgn that defined the shape of the skin. This could be done using
repetitive calls to
CRgn::CombineRgn for part of the image you
wanted to see on the dialog. After creating the whole region you need to call
CWnd::SetWindowRgn with a handle to the
From Windows 2000 a new API
SetLayeredWindowAttributes has been added to User32.dll. This
class uses that to create skinned dialogs. However the background bitmap feature
is not dependent on OS version and can be used on any version of Windows.
Using The Code
<!-- start a block of source code -->The class can be used using the following steps
Add the files CDialogSK.h and CDialogSK.cpp to your project.
Include CDialogSK.h in the .h file for your dialog class
Replace all occurrences of "
CDialogSK" in the .h and .cpp files for your dialog class
If you plan to use a background image (bitmap) go to dialog properties,
styles tab and make Style=Popup, Border=None, and uncheck the "Title
Bar" check box.
At the end of
OnInitDialog of your dialog class add calls to the appropriate
EnableEasyMove(); SetBitmap (IDB_BACKGROUND); SetStyle (LO_RESIZE); SetTransparentColor(RGB(0, 255, 0));
- If you want to change the window style later you can call any of these
method anywhere in your code at run time.
- If for example you want to make a circular dialog. Create a image which has a blue circle on a green background.
SetBitmap with the path to the image and call
passing the color of background (green). This will remove the background
from view and you will get a circular window.
The following methods are present in
DWORD SetBitmap (HBITMAP hBitmap); Sets a background bitmap based on a
DWORD SetBitmap (int nBitmap); Sets a background bitmap based on a resource ID.
DWORD SetBitmap (LPCTSTR lpszFileName); Sets a background bitmap based on a Windows bitmap (.bmp) file.
void SetStyle (LayOutStyle style); Sets the bitmap layout style. Can be any of
LO_TILE (tile image),
LO_CENTER (center image),
LO_STRETCH (stretch image to fit dialog),
(resize dialog to fit the image).
void EnableEasyMove (BOOL pEnable = TRUE); If called with TRUE then you can move the dialog by clicking anywhere in the
client area of the dialog.
BOOL SetTransparent (BYTE bAlpha); Make the dialog as a whole transparent. Range is 0(transparent) - 255
(opaque). This works only on Windows2000 and above (WinXP).
BOOL SetTransparentColor (COLORREF col, BOOL bTrans = TRUE); Make a particular color transparent. This works only on Windows2000 and
above (WinXP). This can be used to create dialog in which you can see
through parts of the dialog.
- This is the initial version. Date Posted: July 01, 2003