Tree2.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:2k
- // Tree2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "DevDemo.h"
- #include "Tree2.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTree2
- IMPLEMENT_DYNCREATE(CTree2, CTreeView)
- CTree2::CTree2()
- {
- }
- CTree2::~CTree2()
- {
- }
- BEGIN_MESSAGE_MAP(CTree2, CTreeView)
- //{{AFX_MSG_MAP(CTree2)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTree2 drawing
- void CTree2::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- // TODO: add draw code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CTree2 diagnostics
- #ifdef _DEBUG
- void CTree2::AssertValid() const
- {
- CTreeView::AssertValid();
- }
- void CTree2::Dump(CDumpContext& dc) const
- {
- CTreeView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CTree2 message handlers
- //修改标签窗口2的外观
- void CTree2::OnInitialUpdate()
- {
- CTreeView::OnInitialUpdate();
- CTreeCtrl& m_pTreeCtrl=GetTreeCtrl( );
- CString msg;
- //为目录树建立图像列表
- m_ImageList.Create (IDB_IL_CLASS, 16, 1, RGB(0,255,0));
- m_pTreeCtrl.SetImageList (&m_ImageList, TVSIL_NORMAL);
-
- CString strTreeItems[] = { _T("项目"), _T("类名"), _T("Globals") };
- //加入根节点
- HTREEITEM htItem = m_pTreeCtrl.InsertItem(strTreeItems[0]);
- m_pTreeCtrl.SetItemState( htItem, TVIS_BOLD, TVIS_BOLD );
- //加入子节点
- for( int i = 1; i < 8; i++ )
- {
- msg.Format("%d",i);
- m_pTreeCtrl.InsertItem (strTreeItems[1]+msg, 1, 1, htItem, TVI_LAST);
- }
-
- //加入子节点2
- m_pTreeCtrl.InsertItem (strTreeItems[2], 2, 3, htItem, TVI_LAST);
- //展开目录
- m_pTreeCtrl.Expand(htItem, TVE_EXPAND);
- }
- BOOL CTree2::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Add your specialized code here and/or call the base class
- cs.style|=TVS_HASLINES|TVS_LINESATROOT;
- return CTreeView::PreCreateWindow(cs);
- }
- BOOL CTree2::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
- }