Click here to Skip to main content
15,891,951 members
Articles / Desktop Programming / MFC

CStaticTreeCtrl - A CStatic derived custom Tree control

Rate me:
Please Sign up or sign in to vote.
4.95/5 (82 votes)
1 May 200617 min read 327.7K   13.3K   169  
Step-by-step creation of a custom Tree control from a CStatic control, implementing basic functionality, eye-candy (font, bitmap background, etc.), scrolling (bars and wheel), multiline (wrapping) text, and audio context menu.
// DLG_TreeNodeText.cpp : implementation file
//

#include "stdafx.h"
#include "customtreecontrol.h"
#include "DLG_TreeNodeText.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDLG_TreeNodeText dialog


CDLG_TreeNodeText::CDLG_TreeNodeText(CWnd* pParent /*=NULL*/)
	: CDialog(CDLG_TreeNodeText::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDLG_TreeNodeText)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDLG_TreeNodeText::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDLG_TreeNodeText)
	DDX_Control(pDX, IDC_EF_TEXT, m_EF_Text);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDLG_TreeNodeText, CDialog)
	//{{AFX_MSG_MAP(CDLG_TreeNodeText)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDLG_TreeNodeText message handlers

BOOL CDLG_TreeNodeText::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// TODO: Add extra initialization here
	m_EF_Text.SetWindowText( m_csItemText );
	m_EF_Text.SetFocus();

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

void CDLG_TreeNodeText::OnOK() 
{
	m_EF_Text.GetWindowText( m_csItemText );

	CDialog::OnOK();
}

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 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


Written By
Japan Japan
Louis Armstrong, Count Basie, Chick Corea, Miles Davis, Benny Goodman, Spyro Gyra, Dizzy Gillespie, Keith Jarrett, Leroy Jenkins, Yusef Lateef, Al Di Meola, Glenn Miller, McCoy Tyner, Cecil Taylor, John Coltrane, Duke Ellington, Bill Evans, Ella Fitzgerald, Jean-Luc Ponty, John McLaughlin, Fats Navarro, Tito Puente, Paul Whiteman, Sun Ra, Caravan, Joe Farrell, Paco de Lucia, Weather Report, Charles Mingus, Pat Metheny, Charlie Parker, Charlie Byrd, Mahavishnu Orchestra, Wynton Marsalis, Return to Forever, Julien Loureau, Thelonious Monk, Max Roach , Pharaoh Sanders, Albert Ayler, Ornette Coleman, Sidney Bechet,...

Comments and Discussions