Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A VISTA style dialog for windows 2000/xp/2003

0.00/5 (No votes)
15 May 2007 1  
The windows in the VISTA is very beautiful, I am always wanting to bring them to other OS, such as Win2K XP 2K3

Screenshot - demo3.jpg

Introduction

The glass style window in VISITA is very beautiful, what I am doing now is to bring them to WINNT5.0 + (Win2K/XP/2K3)

Background

Since WinNT5.0, M$ added two new APIs for providing semi-transparent window.
The SetLayeredWindowAttributes function can set the alpha value for an entire window.
The UpdateLayeredWindow function updates the position, size, shape, content, and translucency of a layered window.

However, when I choose the UpdateLayeredWindow, I found that there are many problems.
1. No WM_PAINT message I can get. Usually, many people use WM_TIMER to redraw their layered window, that is a bad thing I hate. Since it changed the way we are always going, and the result is not good.
2. The common controls on the layered window should be drawn by youself. It also changed the way we are always going. what I want is: just place some controls on the layered window, I do not want to write any more code to display them.

So I need a way to ride all of these ones.

How to use

#include "./ui/TransparentDialogBase.h"

using namespace UI;

// CMySampleDlg dialog

class CMySampleDlg : public CTransparentDialogBase

CMySampleDlg::CMySampleDlg(CWnd* pParent /*=NULL*/)
 : CTransparentDialogBase( _T("bg.png"), CMySampleDlg::IDD, pParent)
{
}

The dialog need be derived from the class CTransparentDialogBase, and the first parameter in the constructor is the PNG file name.
Then just change the layout of the dialog as what you want.

How it works

When the MySampleDlg created, we use SetLayeredWindowAttribute to make this window almost transparent.( The dialog is almost disappeared but we can still get the messages for the window, the alpha value I choose is 5)
Then it creates another window with WS_EX_LAYERED | WS_EX_TRANSPARENT options. This new window has the same size / position with the original one.
When the MySampleDlg get WM_PAINT message, it draw the fake window with UpdateLayeredWindow.
Also, for each child control on the MySampleDlg, we use WM_PRINT message to retrive its content.


History

2007-05-09 created

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here