home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / viewcmn.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  3KB  |  123 lines

  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.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CORE4_SEG
  14. #pragma code_seg(AFX_CORE4_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. #define new DEBUG_NEW
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CListView
  26.  
  27. BEGIN_MESSAGE_MAP(CListView, CCtrlView)
  28.     //{{AFX_MSG_MAP(CListView)
  29.     ON_WM_NCDESTROY()
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. BOOL CListView::PreCreateWindow(CREATESTRUCT& cs)
  34. {
  35.     return CCtrlView::PreCreateWindow(cs);
  36. }
  37.  
  38. void CListView::DrawItem(LPDRAWITEMSTRUCT)
  39. {
  40.     ASSERT(FALSE);
  41. }
  42.  
  43. BOOL CListView::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam,
  44.     LRESULT* pResult)
  45. {
  46.     if (message != WM_DRAWITEM)
  47.         return CCtrlView::OnChildNotify(message, wParam, lParam, pResult);
  48.  
  49.     ASSERT(pResult == NULL);       // no return value expected
  50.     UNUSED(pResult); // unused in release builds
  51.  
  52.     DrawItem((LPDRAWITEMSTRUCT)lParam);
  53.     return TRUE;
  54. }
  55.  
  56. void CListView::RemoveImageList(int nImageList)
  57. {
  58.     HIMAGELIST h = (HIMAGELIST)SendMessage(LVM_GETIMAGELIST,
  59.         (WPARAM)nImageList);
  60.     if (CImageList::FromHandlePermanent(h) != NULL)
  61.         SendMessage(LVM_SETIMAGELIST, (WPARAM)nImageList, NULL);
  62. }
  63.  
  64. void CListView::OnNcDestroy()
  65. {
  66.     RemoveImageList(LVSIL_NORMAL);
  67.     RemoveImageList(LVSIL_SMALL);
  68.     RemoveImageList(LVSIL_STATE);
  69.  
  70.     CCtrlView::OnNcDestroy();
  71. }
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CTreeView
  75.  
  76. BEGIN_MESSAGE_MAP(CTreeView, CCtrlView)
  77.     //{{AFX_MSG_MAP(CTreeView)
  78.     ON_WM_DESTROY()
  79.     //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81.  
  82. BOOL CTreeView::PreCreateWindow(CREATESTRUCT& cs)
  83. {
  84.     return CCtrlView::PreCreateWindow(cs);
  85. }
  86.  
  87. void CTreeView::RemoveImageList(int nImageList)
  88. {
  89.     HIMAGELIST h = (HIMAGELIST)SendMessage(TVM_GETIMAGELIST,
  90.         (WPARAM)nImageList);
  91.     if (CImageList::FromHandlePermanent(h) != NULL)
  92.         SendMessage(TVM_SETIMAGELIST, (WPARAM)nImageList, NULL);
  93. }
  94.  
  95. void CTreeView::OnDestroy()
  96. {
  97.     RemoveImageList(LVSIL_NORMAL);
  98.     RemoveImageList(LVSIL_STATE);
  99.  
  100.     CCtrlView::OnDestroy();
  101. }
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104.  
  105. #ifndef _AFX_ENABLE_INLINES
  106.  
  107. static const char _szAfxWinInl[] = "afxcview.inl";
  108. #undef THIS_FILE
  109. #define THIS_FILE _szAfxWinInl
  110. #define _AFXCVIEW_INLINE
  111. #include "afxcview.inl"
  112.  
  113. #endif //_AFX_ENABLE_INLINES
  114.  
  115. #ifdef AFX_INIT_SEG
  116. #pragma code_seg(AFX_INIT_SEG)
  117. #endif
  118.  
  119. IMPLEMENT_DYNCREATE(CListView, CCtrlView)
  120. IMPLEMENT_DYNCREATE(CTreeView, CCtrlView)
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123.