home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / database / mfcrows / mfcrowview.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  138 lines

  1. // MFCRowView.cpp : implementation of the CMFCRowView 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 "MFCRow.h"
  15.  
  16. #include "MFCRowSet.h"
  17. #include "MFCRowDoc.h"
  18. #include "MFCRowView.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMFCRowView
  28.  
  29. IMPLEMENT_DYNCREATE(CMFCRowView, COleDBRecordView)
  30.  
  31. BEGIN_MESSAGE_MAP(CMFCRowView, COleDBRecordView)
  32.     //{{AFX_MSG_MAP(CMFCRowView)
  33.         // NOTE - the ClassWizard will add and remove mapping macros here.
  34.         //    DO NOT EDIT what you see in these blocks of generated code!
  35.     //}}AFX_MSG_MAP
  36.     // Standard printing commands
  37.     ON_COMMAND(ID_FILE_PRINT, COleDBRecordView::OnFilePrint)
  38.     ON_COMMAND(ID_FILE_PRINT_DIRECT, COleDBRecordView::OnFilePrint)
  39.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, COleDBRecordView::OnFilePrintPreview)
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CMFCRowView construction/destruction
  44.  
  45. CMFCRowView::CMFCRowView()
  46.     : COleDBRecordView(CMFCRowView::IDD)
  47. {
  48.     //{{AFX_DATA_INIT(CMFCRowView)
  49.     m_pSet = NULL;
  50.     //}}AFX_DATA_INIT
  51.     // TODO: add construction code here
  52.  
  53. }
  54.  
  55. CMFCRowView::~CMFCRowView()
  56. {
  57. }
  58.  
  59. BOOL CMFCRowView::PreCreateWindow(CREATESTRUCT& cs)
  60. {
  61.     // TODO: Modify the Window class or styles here by modifying
  62.     //  the CREATESTRUCT cs
  63.  
  64.     return COleDBRecordView::PreCreateWindow(cs);
  65. }
  66.  
  67. void CMFCRowView::OnInitialUpdate()
  68. {
  69.     m_pSet = &GetDocument()->m_mFCRowSet;
  70.     {
  71.         CWaitCursor wait;
  72.         m_pSet->Open();
  73.     }
  74.     COleDBRecordView::OnInitialUpdate();
  75. }
  76.  
  77. void CMFCRowView::DoDataExchange(CDataExchange* pDX)
  78. {
  79.     COleDBRecordView::DoDataExchange(pDX);
  80.  
  81.     //{{AFX_DATA_MAP(CMFCRowView)
  82.     DDX_Text(pDX, IDC_ID, m_pSet->m_nProductID);
  83.     DDV_MaxChars(pDX, m_pSet->m_szName, 40);
  84.     //}}AFX_DATA_MAP
  85.     DDX_Text(pDX, IDC_NAME, m_pSet->m_szName, 40);
  86. }
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CMFCRowView printing
  90.  
  91. BOOL CMFCRowView::OnPreparePrinting(CPrintInfo* pInfo)
  92. {
  93.     // default preparation
  94.     return DoPreparePrinting(pInfo);
  95. }
  96.  
  97. void CMFCRowView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  98. {
  99.     // TODO: add extra initialization before printing
  100. }
  101.  
  102. void CMFCRowView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  103. {
  104.     // TODO: add cleanup after printing
  105. }
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CMFCRowView diagnostics
  109.  
  110. #ifdef _DEBUG
  111. void CMFCRowView::AssertValid() const
  112. {
  113.     COleDBRecordView::AssertValid();
  114. }
  115.  
  116. void CMFCRowView::Dump(CDumpContext& dc) const
  117. {
  118.     COleDBRecordView::Dump(dc);
  119. }
  120.  
  121. CMFCRowDoc* CMFCRowView::GetDocument() // non-debug version is inline
  122. {
  123.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCRowDoc)));
  124.     return (CMFCRowDoc*)m_pDocument;
  125. }
  126. #endif //_DEBUG
  127.  
  128. /////////////////////////////////////////////////////////////////////////////
  129. // CMFCRowView database support
  130. CRowset* CMFCRowView::OnGetRowset()
  131. {
  132.     return m_pSet;
  133. }
  134.  
  135.  
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CMFCRowView message handlers
  138.