ComponentOne VSView Reporting Edition
Implementing Custom Recordsets in Visual C++ 6.0

To implement a custom recordset in Visual C++ 6.0, follow these steps (for a complete example, see the CustomData project in the Samples/VC directory):

  1. Create a new project with COM support (MFC or ATL) and add the following statement to the StdAfx.h file (fix the path as appropriate so VC++ can find the OCX file):

    Example Title
    Copy Code
    #import "e:\ocx\VSRpt8.ocx" no_namespace
    

    This will create wrapper classes for the VSReport8 objects, including the definition of the IVSReportRecordset interface.

  2. Create a new class that implements the IVSReportRecordset interface. For a complete sample, see the MyReportDataSource.h file in the Samples/VC directory.

  3. Add a VSReport8 and a VSPrinter8 control to your application. In an MFC dialog-based application, you can do this by right-clicking the dialog and selecting the Insert ActiveX Control menu.

  4. Add the class variables needed to communicate with the new controls. In an MFC dialog-based application, you can do this by control-double-clicking each control, then entering a variable name in the dialog. For example, m_Report and m_Printer.

  5. Load a report definition into the m_Report control. You can do this by right clicking the control, selecting the Properties menu, and using the Load Report tab.

  6. To create reports, create an instance of the data source class, assign it to the m_Report control, and render it on the m_Printer control. In an MFC dialog-based application, you can do this with the following code:

    Example Title
    Copy Code
    #include "DataSource.h"          // created by MFC
    
    #include "MyReportDataSource.h"  // custom data source
    
     
    
    void CCustomDataDlg::OnRenderCustom()
    
    {
    
      // create custom data source
    
      CMyReportDataSource cds;
    
    
      // assign it to control
    
      CDataSource ds = m_Report.GetDataSource();
    
      ds.SetRecordset(cds.GetUnknown());
    
    
      // render it
    
      m_Report.Render((IDispatch*)m_Printer.GetControlUnknown());
    
    }
    

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback