home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / msdev / bin / mfcclswz.dll / SRCDATA / RECVIEW.CPP < prev    next >
Encoding:
Text File  |  1996-07-12  |  2.8 KB  |  138 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // %1
  3.  
  4. IMPLEMENT_DYNCREATE(%1, CRecordView)
  5.  
  6. %1::%1()
  7.     : CRecordView(%1::IDD)
  8. {
  9. $$IF(OLEAUTO)
  10.     EnableAutomation();
  11. $$ENDIF
  12. $$IF(OLECREATE)
  13.     
  14.     // To keep the application running as long as an OLE automation 
  15.     //    object is active, the constructor calls AfxOleLockApp.
  16.     
  17.     AfxOleLockApp();
  18.  
  19. $$ENDIF
  20.     //{{AFX_DATA_INIT(%1)
  21.     m_pSet = NULL;
  22.     //}}AFX_DATA_INIT
  23. }
  24.  
  25. %1::~%1()
  26. {
  27. $$IF(OLECREATE)
  28.     // To terminate the application when all objects created with
  29.     //     with OLE automation, the destructor calls AfxOleUnlockApp.
  30.     
  31.     AfxOleUnlockApp();
  32. $$ENDIF
  33. }
  34. $$IF(OLEAUTO)
  35.  
  36. void %1::OnFinalRelease()
  37. {
  38.     // When the last reference for an automation object is released
  39.     // OnFinalRelease is called.  The base class will automatically
  40.     // deletes the object.  Add additional cleanup required for your
  41.     // object before calling the base class.
  42.  
  43.     CRecordView::OnFinalRelease();
  44. }
  45. $$ENDIF
  46.  
  47. void %1::DoDataExchange(CDataExchange* pDX)
  48. {
  49.     CRecordView::DoDataExchange(pDX);
  50.     //{{AFX_DATA_MAP(%1)
  51.         // NOTE: the ClassWizard will add DDX and DDV calls here
  52.     //}}AFX_DATA_MAP
  53. }
  54.  
  55.  
  56. BEGIN_MESSAGE_MAP(%1, CRecordView)
  57.     //{{AFX_MSG_MAP(%1)
  58.         // NOTE - the ClassWizard will add and remove mapping macros here.
  59.     //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. $$IF(OLEAUTO)
  62.  
  63. BEGIN_DISPATCH_MAP(%1, CRecordView)
  64.     //{{AFX_DISPATCH_MAP(%1)
  65.         // NOTE - the ClassWizard will add and remove mapping macros here.
  66.     //}}AFX_DISPATCH_MAP
  67. END_DISPATCH_MAP()
  68.  
  69. // Note: we add support for IID_I%c to support typesafe binding
  70. //  from VBA.  This IID must match the GUID that is attached to the 
  71. //  dispinterface in the .ODL file.
  72.  
  73. // {%b}
  74. static const IID IID_I%c =
  75. %d;
  76.  
  77. BEGIN_INTERFACE_MAP(%1, CRecordView)
  78.     INTERFACE_PART(%1, IID_I%c, Dispatch)
  79. END_INTERFACE_MAP()
  80. $$ENDIF //OLEAUTO
  81. $$IF(OLECREATE)
  82.  
  83. // {%e}
  84. IMPLEMENT_OLECREATE(%1, "%6", %7)
  85. $$ENDIF //OLECREATE
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88. // %1 diagnostics
  89.  
  90. #ifdef _DEBUG
  91. void %1::AssertValid() const
  92. {
  93.     CRecordView::AssertValid();
  94. }
  95.  
  96. void %1::Dump(CDumpContext& dc) const
  97. {
  98.     CRecordView::Dump(dc);
  99. }
  100. #endif //_DEBUG
  101.  
  102. /////////////////////////////////////////////////////////////////////////////
  103. // %1 message handlers
  104.  
  105. CRecordset* %1::OnGetRecordset()
  106. {
  107.     if (m_pSet != NULL)
  108.         return m_pSet;
  109.  
  110.     m_pSet = new %8(NULL);
  111.     m_pSet->Open();
  112.  
  113.     return m_pSet;
  114. }
  115.  
  116. %8* %1::GetRecordset()
  117. {
  118.     %8* pData = (%8*) OnGetRecordset();
  119.     ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(%8)));
  120.     return pData;
  121. }
  122.  
  123. void %1::OnInitialUpdate()
  124. {
  125.     BeginWaitCursor();
  126.     GetRecordset();
  127.     CRecordView::OnInitialUpdate();
  128.     if (m_pSet->IsOpen())
  129.     {
  130.         CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();
  131.         CString strTable = m_pSet->GetTableName();
  132.         if (!strTable.IsEmpty())
  133.             strTitle += _T(":") + strTable;
  134.         GetDocument()->SetTitle(strTitle);
  135.     }
  136.     EndWaitCursor();
  137. }