www.pudn.com > TreeAndList.rar > LeftView.cpp


// LeftView.cpp : implementation file 
// 
 
 
////*点击class view,然后用右键newclass建立这个类,继承CTreeView。建工程时继承CListView。 
///***/////// 
 
 
#include "stdafx.h" 
#include "TreeAndList.h" 
#include "LeftView.h" 
//#include "TreeAndListView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CLeftView 
 
IMPLEMENT_DYNCREATE(CLeftView, CTreeView) 
 
CLeftView::CLeftView() 
{ 
} 
 
CLeftView::~CLeftView() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CLeftView, CTreeView) 
	//{{AFX_MSG_MAP(CLeftView) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
 
		//shuangquan@@@@@@@@@@@@@@@@@@@@@@@@@@@@消息映射 
			ON_NOTIFY_REFLECT(TVN_SELCHANGED, selectChangeListView) 
	//}}AFX_MSG_MAP 
 
 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CLeftView drawing 
 
void CLeftView::OnDraw(CDC* pDC) 
{ 
	CDocument* pDoc = GetDocument(); 
	// TODO: add draw code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CLeftView diagnostics 
 
#ifdef _DEBUG 
void CLeftView::AssertValid() const 
{ 
	CTreeView::AssertValid(); 
} 
 
void CLeftView::Dump(CDumpContext& dc) const 
{ 
	CTreeView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CLeftView message handlers 
 
 
 
/* 
 *自己添加的函数,可以手工添加或者用鼠标右键然后add function。都是一样的。 
 */ 
 
void CLeftView::OnInitialUpdate()  
{ 
	CTreeView::OnInitialUpdate(); 
	//ImgTree.Create (16,16,ILC_COLOR|ILC_MASK,3,3);//创建图标列表 
	//ImgTree.Add (AfxGetApp()->LoadIcon (IDI_CK)); 
	//ImgTree.Add (AfxGetApp()->LoadIcon (IDI_BASE_INFO)); 
//	ImgTree.Add (AfxGetApp()->LoadIcon (IDI_INPUT)); 
 
	CTreeCtrl& CtlTree=(CTreeCtrl&)GetTreeCtrl (); 
	CtlTree.SetBkColor (RGB(210,230,190)); 
//	CtlTree.SetImageList (&ImgTree,TVSIL_NORMAL); 
	int i=0; 
	TV_INSERTSTRUCT tvRoot;//树根 
    TV_INSERTSTRUCT tvSecond;//树枝 
	TV_INSERTSTRUCT tvThree;//树叶 
	tvRoot.hParent=NULL; 
	tvRoot.item.pszText="仓库管理"; 
	tvRoot.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; 
    tvRoot.item.iImage=i; 
	tvRoot.item.iSelectedImage=i; 
	HTREEITEM item_root=CtlTree.InsertItem (&tvRoot); 
    int ii; 
	CString strSecond[2]={"基本信息管理","入库管理"}; 
	CString strThree[2][3]={{"操作员管理","商品信息管理","库存信息管理"},{"商品入库","入库退货"}}; 
	for(i=0;i<2;i++) 
	{ 
		tvSecond.hParent=item_root; 
		tvSecond.item.pszText=(LPTSTR)(LPCTSTR)strSecond[i]; 
		tvSecond.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; 
        tvSecond.item.iImage=1; 
	    tvSecond.item.iSelectedImage=2; 
		HTREEITEM item_second=CtlTree.InsertItem (&tvSecond); 
		switch(i) 
		{ 
		case 0: 
			ii=3; 
			break; 
        case 1: 
			ii=2; 
			break; 
		default: 
			break; 
 
		} 
		for(int j=0;jGetPane(0,1); 
	m_li->changeDataFromTreeViewOnClick(str); 
	*pResult = 0; 
}