Click here to Skip to main content
15,886,518 members
Articles / Desktop Programming / Windows Forms

Cool, Semi-transparent and Shaped Dialogs with Standard Controls for Windows 2000 and Above

Rate me:
Please Sign up or sign in to vote.
4.85/5 (95 votes)
28 Sep 2012CPOL3 min read 2.9M   32.8K   350  
This article tries to find a way to show Windows standard controls on layered windows. Provides both Native MFC and WinForms source code.
// Demo3Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "SemiTransparentDialogWithStandardCtrls.h"
#include "Demo3Dlg.h"


// CDemo3Dlg dialog

IMPLEMENT_DYNAMIC(CDemo3Dlg, CDialog)

CDemo3Dlg::CDemo3Dlg(CWnd* pParent /*=NULL*/)
	: CImgDialogBase(CDemo3Dlg::IDD
	, IDB_PNG_DLG2
	, _T("PNG")
	, AfxGetResourceHandle()
	, pParent
	)
{

}

CDemo3Dlg::~CDemo3Dlg()
{
}

void CDemo3Dlg::DoDataExchange(CDataExchange* pDX)
{
	CImgDialogBase::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE1, m_ctlTree);
}


BEGIN_MESSAGE_MAP(CDemo3Dlg, CImgDialogBase)
END_MESSAGE_MAP()


// CDemo3Dlg message handlers

void CDemo3Dlg::PostNcDestroy()
{
	CImgDialogBase::PostNcDestroy();
	delete this;
}

BOOL CDemo3Dlg::OnInitDialog()
{
	CImgDialogBase::OnInitDialog();

	HTREEITEM hRoot = m_ctlTree.InsertItem( _T("Root") );
	for( int i = 0; i < 100; i++)
	{
		CString strTemp;
		strTemp.Format( _T("Node %02d"), i);
		m_ctlTree.InsertItem( strTemp, hRoot);
	}
	m_ctlTree.Expand( hRoot, TVE_EXPAND);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
China China
Jerry is from China. He was captivated by computer programming since 13 years old when first time played with Q-Basic.



  • Windows / Linux & C++
  • iOS & Obj-C
  • .Net & C#
  • Flex/Flash & ActionScript
  • HTML / CSS / Javascript
  • Gaming Server programming / video, audio processing / image & graphics


Contact: vcer(at)qq.com
Chinese Blog: http://blog.csdn.net/wangjia184

Comments and Discussions