www.gusucode.com > VC++多文档树状控件菜单的应用示例-源码程序 > VC++多文档树状控件菜单的应用示例-源码程序/code/MyTree.cpp

    // MyTree.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "ctreecontrolbar.h"
#include "MyTree.h"

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

/////////////////////////////////////////////////////////////////////////////
// MyTree

MyTree::MyTree()
{	m_uFlags=0;
}

MyTree::~MyTree()
{
}


BEGIN_MESSAGE_MAP(MyTree, CTreeCtrl)
	//{{AFX_MSG_MAP(MyTree)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyTree message handlers



void MyTree::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	 	HTREEITEM hItem =HitTest(point, &m_uFlags);
	 	//进行的是与运算,对于 二进制数来说都为1的情况下结果为1

	 	if ( (m_uFlags&TVHT_ONITEMLABEL ))
	 	{
		
			CCTreeControlBarApp *pApp=(CCTreeControlBarApp *)AfxGetApp();
			pApp->pView->m_Title=GetItemText(hItem);;
			pApp->pView->Invalidate(TRUE);
			SelectItem(hItem);
	 	}
	 	
	CTreeCtrl::OnLButtonDown(nFlags, point);
}