home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / dbvlist / dbvlistview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.8 KB  |  115 lines

  1. // DBVListView.cpp : implementation of the CDBVListView class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "DBVList.h"
  15.  
  16. #include "DBVListSet.h"
  17. #include "DBVListDoc.h"
  18. #include "DBVListView.h"
  19. #include "MainFrm.h"
  20. #include "EmpView.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CDBVListView
  30.  
  31. IMPLEMENT_DYNCREATE(CDBVListView, CFormView)
  32.  
  33. BEGIN_MESSAGE_MAP(CDBVListView, CFormView)
  34.     //{{AFX_MSG_MAP(CDBVListView)
  35.     ON_BN_CLICKED(IDC_FETCH, OnFetch)
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDBVListView construction/destruction
  41.  
  42. CDBVListView::CDBVListView()
  43.     : CFormView(CDBVListView::IDD)
  44. {
  45.     //{{AFX_DATA_INIT(CDBVListView)
  46.     m_pSet = NULL;
  47.     m_strDiv = _T("");
  48.     //}}AFX_DATA_INIT
  49. }
  50.  
  51. CDBVListView::~CDBVListView()
  52. {
  53. }
  54.  
  55. void CDBVListView::DoDataExchange(CDataExchange* pDX)
  56. {
  57.     CFormView::DoDataExchange(pDX);
  58.     //{{AFX_DATA_MAP(CDBVListView)
  59.     DDX_CBString(pDX, IDC_DIV, m_strDiv);
  60.     //}}AFX_DATA_MAP
  61. }
  62.  
  63. BOOL CDBVListView::PreCreateWindow(CREATESTRUCT& cs)
  64. {
  65.     return CFormView::PreCreateWindow(cs);
  66. }
  67.  
  68. void CDBVListView::OnInitialUpdate()
  69. {
  70.     m_pSet = &GetDocument()->m_dBVListSet;
  71.     CFormView::OnInitialUpdate();
  72. }
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CDBVListView diagnostics
  76.  
  77. #ifdef _DEBUG
  78. void CDBVListView::AssertValid() const
  79. {
  80.     CFormView::AssertValid();
  81. }
  82.  
  83. void CDBVListView::Dump(CDumpContext& dc) const
  84. {
  85.     CFormView::Dump(dc);
  86. }
  87.  
  88. CDBVListDoc* CDBVListView::GetDocument() // non-debug version is inline
  89. {
  90.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDBVListDoc)));
  91.     return (CDBVListDoc*)m_pDocument;
  92. }
  93. #endif //_DEBUG
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CDBVListView database support
  97. CDaoRecordset* CDBVListView::OnGetRecordset()
  98. {
  99.     return m_pSet;
  100. }
  101.  
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CDBVListView message handlers
  105.  
  106. void CDBVListView::OnFetch()
  107. {
  108.     CMainFrame* pFrame=static_cast<CMainFrame*>(AfxGetMainWnd());
  109.     CEmpView* pView=static_cast<CEmpView*>(pFrame->m_wndSplitter.GetPane(1,0));
  110.  
  111.     // set the filter for viewing the database to the currently selected division
  112.     UpdateData(TRUE);
  113.     pView->UpdateFilter(m_strDiv);
  114. }
  115.