TREEVIEWRESOURCE.CPP
上传用户:gzfeiyu199
上传日期:2021-09-15
资源大小:68k
文件大小:3k
源码类别:

编辑框

开发平台:

Visual C++

  1. // TreeViewResource.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Demo_DevStudio.h"
  5. #include "TreeViewResource.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CTreeViewResource
  13. IMPLEMENT_DYNCREATE(CTreeViewResource, CTreeView)
  14. CTreeViewResource::CTreeViewResource()
  15. {
  16. }
  17. CTreeViewResource::~CTreeViewResource()
  18. {
  19. }
  20. BEGIN_MESSAGE_MAP(CTreeViewResource, CTreeView)
  21. //{{AFX_MSG_MAP(CTreeViewResource)
  22. ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding)
  23. ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
  24. ON_WM_CREATE()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CTreeViewResource drawing
  29. void CTreeViewResource::OnDraw(CDC* pDC)
  30. {
  31. CDocument* pDoc = GetDocument();
  32. // TODO: add draw code here
  33. }
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CTreeViewResource diagnostics
  36. #ifdef _DEBUG
  37. void CTreeViewResource::AssertValid() const
  38. {
  39. CTreeView::AssertValid();
  40. }
  41. void CTreeViewResource::Dump(CDumpContext& dc) const
  42. {
  43. CTreeView::Dump(dc);
  44. }
  45. #endif //_DEBUG
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CTreeViewResource message handlers
  48. void CTreeViewResource::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) 
  49. {
  50. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  51. // TODO: Add your control notification handler code here
  52. *pResult = 0;
  53. }
  54. void CTreeViewResource::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 
  55. {
  56. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  57. // TODO: Add your control notification handler code here
  58. *pResult = 0;
  59. }
  60. static CString csTree[] =
  61. {
  62. _T("Demo resources"),
  63. _T("Accelerator"),
  64. _T("Bitmap"),
  65. _T("Dialog"),
  66. _T("Icon"),
  67. _T("Menu"),
  68. _T("String Table"),
  69. _T("Toolbar"),
  70. _T("Version")
  71. };
  72. int CTreeViewResource::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  73. {
  74. if (CTreeView::OnCreate(lpCreateStruct) == -1)
  75. return -1;
  76. // TODO: Add your specialized creation code here
  77. m_TreeCtrl = &GetTreeCtrl();
  78. // create the image list for the tree control
  79. m_ImageList.Create (IDB_IL_RSRC, 16, 1, RGB(0,255,0));
  80. m_TreeCtrl->SetImageList (&m_ImageList, TVSIL_NORMAL);
  81. // add the parent item
  82. HTREEITEM htItem = m_TreeCtrl->InsertItem (csTree[0], 1, 1);
  83. m_TreeCtrl->SetItemState (htItem, TVIS_BOLD, TVIS_BOLD);
  84. // add children items
  85. for (int i = 1; i < 9; i++) {
  86. m_TreeCtrl->InsertItem (csTree[i], 0, 1, htItem, TVI_LAST);
  87. }
  88. m_TreeCtrl->Expand (htItem, TVE_EXPAND);
  89. return 0;
  90. }
  91. BOOL CTreeViewResource::PreCreateWindow(CREATESTRUCT& cs) 
  92. {
  93. // TODO: Add your specialized code here and/or call the base class
  94. cs.style |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
  95. return CTreeView::PreCreateWindow(cs);
  96. }