TREEVIEWCLASS.CPP
资源名称:shell_8.zip [点击查看]
上传用户:gzfeiyu199
上传日期:2021-09-15
资源大小:68k
文件大小:3k
源码类别:
编辑框
开发平台:
Visual C++
- // TreeViewClass.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Demo_DevStudio.h"
- #include "TreeViewClass.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTreeViewClass
- IMPLEMENT_DYNCREATE(CTreeViewClass, CTreeView)
- CTreeViewClass::CTreeViewClass()
- {
- }
- CTreeViewClass::~CTreeViewClass()
- {
- }
- BEGIN_MESSAGE_MAP(CTreeViewClass, CTreeView)
- //{{AFX_MSG_MAP(CTreeViewClass)
- ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding)
- ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTreeViewClass drawing
- void CTreeViewClass::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- // TODO: add draw code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CTreeViewClass diagnostics
- #ifdef _DEBUG
- void CTreeViewClass::AssertValid() const
- {
- CTreeView::AssertValid();
- }
- void CTreeViewClass::Dump(CDumpContext& dc) const
- {
- CTreeView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CTreeViewClass message handlers
- void CTreeViewClass::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- *pResult = 0;
- }
- void CTreeViewClass::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- *pResult = 0;
- }
- static CString csTree[] =
- {
- _T("Demo classes"),
- _T("CClassName"),
- _T("Globals")
- };
- int CTreeViewClass::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CTreeView::OnCreate(lpCreateStruct) == -1)
- return -1;
- // TODO: Add your specialized creation code here
- m_TreeCtrl = &GetTreeCtrl();
- // Create the image list for the tree control
- m_ImageList.Create (IDB_IL_CLASS, 16, 1, RGB(0,255,0));
- m_TreeCtrl->SetImageList (&m_ImageList, TVSIL_NORMAL);
- // Add the parent item
- HTREEITEM htItem = m_TreeCtrl->InsertItem(csTree[0]);
- m_TreeCtrl->SetItemState( htItem, TVIS_BOLD, TVIS_BOLD );
- // Add children
- for( int i = 1; i < 8; i++ ) {
- m_TreeCtrl->InsertItem (csTree[1], 1, 1, htItem, TVI_LAST);
- }
- // Add children
- m_TreeCtrl->InsertItem (csTree[2], 2, 3, htItem, TVI_LAST);
- m_TreeCtrl->Expand(htItem, TVE_EXPAND);
- return 0;
- }
- BOOL CTreeViewClass::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Add your specialized code here and/or call the base class
- cs.style |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
- return CTreeView::PreCreateWindow(cs);
- }