Click here to Skip to main content
15,892,965 members
Articles / Desktop Programming / MFC

A Float Tree Control like the Parameter List Control in Visual Studio

Rate me:
Please Sign up or sign in to vote.
3.44/5 (6 votes)
9 Apr 20021 min read 135.2K   2.6K   25  
In Visual Studio, you will find an auto-completion list when you type your code in the IDE. This is a similar control but using a tree.
// vs_treectrlView.cpp : implementation of the CVs_treectrlView class
//

#include "stdafx.h"
#include "vs_treectrl.h"

#include "vs_treectrlDoc.h"
#include "vs_treectrlView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView

IMPLEMENT_DYNCREATE(CVs_treectrlView, CView)

BEGIN_MESSAGE_MAP(CVs_treectrlView, CView)
	//{{AFX_MSG_MAP(CVs_treectrlView)
	ON_WM_LBUTTONUP()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
	ON_MESSAGE(WM_FLOAT_CTRL,OnFloatCtrl)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView construction/destruction

CVs_treectrlView::CVs_treectrlView()
{
	// TODO: add construction code here

}

CVs_treectrlView::~CVs_treectrlView()
{
}

BOOL CVs_treectrlView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView drawing

void CVs_treectrlView::OnDraw(CDC* pDC)
{
	CVs_treectrlDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView printing

BOOL CVs_treectrlView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CVs_treectrlView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CVs_treectrlView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView diagnostics

#ifdef _DEBUG
void CVs_treectrlView::AssertValid() const
{
	CView::AssertValid();
}

void CVs_treectrlView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CVs_treectrlDoc* CVs_treectrlView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVs_treectrlDoc)));
	return (CVs_treectrlDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CVs_treectrlView message handlers

void CVs_treectrlView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	m_Tree.ShowMe (point);
	CView::OnLButtonUp(nFlags, point);
}

void CVs_treectrlView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
		CRect rect(0,0,200,300);
	m_Tree.CreateTree (rect,this,IDB_BITMAP_TREE_ICONS);
	m_Tree.loadXML  ("catalog.xml",TRUE);
	// TODO: Add your specialized code here and/or call the base class
	
}
LRESULT CVs_treectrlView::OnFloatCtrl(WPARAM wParam, LPARAM lParam)
{
	CString str = (BSTR)wParam;
	MessageBox(str);
	m_Tree.ShowWindow (SW_HIDE);
	return 0;
}

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.


Written By
Software Developer (Senior)
China China
I'm write program from 1990. My research field is CAG,CAD and Image processing. I select C/C++, ASP, Java, XML as my usaully developing tools. Occasional , write code in Delphi and VB. I'm using Visual C++ from 1996. If you have anything unclear, e-mail to :zhou_cn123@sina.com Software Engineering and CAD is my mainly research program.

You also can reach me on msn: zhoujohnson@hotmail.com

Comments and Discussions