viewcmn.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #ifdef AFX_CORE4_SEG
  12. #pragma code_seg(AFX_CORE4_SEG)
  13. #endif
  14. #ifdef _DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. #define new DEBUG_NEW
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CListView
  21. BEGIN_MESSAGE_MAP(CListView, CCtrlView)
  22. //{{AFX_MSG_MAP(CListView)
  23. ON_WM_NCDESTROY()
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. BOOL CListView::PreCreateWindow(CREATESTRUCT& cs)
  27. {
  28. return CCtrlView::PreCreateWindow(cs);
  29. }
  30. void CListView::DrawItem(LPDRAWITEMSTRUCT)
  31. {
  32. ASSERT(FALSE);
  33. }
  34. BOOL CListView::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam,
  35. LRESULT* pResult)
  36. {
  37. if (message != WM_DRAWITEM)
  38. return CCtrlView::OnChildNotify(message, wParam, lParam, pResult);
  39. ASSERT(pResult == NULL); // no return value expected
  40. UNUSED(pResult); // unused in release builds
  41. DrawItem((LPDRAWITEMSTRUCT)lParam);
  42. return TRUE;
  43. }
  44. void CListView::RemoveImageList(int nImageList)
  45. {
  46. HIMAGELIST h = (HIMAGELIST)SendMessage(LVM_GETIMAGELIST,
  47. (WPARAM)nImageList);
  48. if (CImageList::FromHandlePermanent(h) != NULL)
  49. SendMessage(LVM_SETIMAGELIST, (WPARAM)nImageList, NULL);
  50. }
  51. void CListView::OnNcDestroy()
  52. {
  53. RemoveImageList(LVSIL_NORMAL);
  54. RemoveImageList(LVSIL_SMALL);
  55. RemoveImageList(LVSIL_STATE);
  56. CCtrlView::OnNcDestroy();
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CTreeView
  60. BEGIN_MESSAGE_MAP(CTreeView, CCtrlView)
  61. //{{AFX_MSG_MAP(CTreeView)
  62. ON_WM_DESTROY()
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. BOOL CTreeView::PreCreateWindow(CREATESTRUCT& cs)
  66. {
  67. return CCtrlView::PreCreateWindow(cs);
  68. }
  69. void CTreeView::RemoveImageList(int nImageList)
  70. {
  71. HIMAGELIST h = (HIMAGELIST)SendMessage(TVM_GETIMAGELIST,
  72. (WPARAM)nImageList);
  73. if (CImageList::FromHandlePermanent(h) != NULL)
  74. SendMessage(TVM_SETIMAGELIST, (WPARAM)nImageList, NULL);
  75. }
  76. void CTreeView::OnDestroy()
  77. {
  78. RemoveImageList(LVSIL_NORMAL);
  79. RemoveImageList(LVSIL_STATE);
  80. CCtrlView::OnDestroy();
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. #ifndef _AFX_ENABLE_INLINES
  84. static const char _szAfxWinInl[] = "afxcview.inl";
  85. #undef THIS_FILE
  86. #define THIS_FILE _szAfxWinInl
  87. #define _AFXCVIEW_INLINE
  88. #include "afxcview.inl"
  89. #endif //_AFX_ENABLE_INLINES
  90. #ifdef AFX_INIT_SEG
  91. #pragma code_seg(AFX_INIT_SEG)
  92. #endif
  93. IMPLEMENT_DYNCREATE(CListView, CCtrlView)
  94. IMPLEMENT_DYNCREATE(CTreeView, CCtrlView)
  95. /////////////////////////////////////////////////////////////////////////////