CRYSTAL REPORT (RDC8) Calling method in a VC6 environment

zhaozj2021-02-11  200

http://jaesyinfo.51.net/vcrdc8/vcrdc8.htm // Source

CRYSTAL REPORT (RDC8) Calling method in a VC6 environment

Author: jaesy Email:. Jaesyinfo@163.net

Seagate Crystal Report (Crystal Report) has always been a leader in the report tool, which is powerful and flexible. In the 8.0 version of Crystal Report, more integrated into COM thinking, which emphasizes the concept of RDC. RDC is an abbreviation for Report Designer Component.

This article mainly shows how to use RDC8 in a VC6 environment, and see the control of report template file * .RPT design and runtime attributes See http://jaesyinfo.51.net.

In Crystal Report, the CRYSTAL REPORT is mainly used by CRPE API. Interested friends can refer to online help. This paper mainly uses RDC methods, and it is also recommended by it now.

Below to establish a dialog-based VC project as an example, explain implementation methods, I hope to help everyone.

Download Sample Project Document Demordc.zip, 46K (Win2000 VC6)

first step:

Create a Crystal Report Template Document Demordc.rpt

In this case, this report does not associate any database.

Step 2:

Establish a dialog-based VC project to accept the default selection, engineering name Demordc.

third step:

Add ActiveX Control: Crystal Report Viewer Control in the project. (Figure 1)

At this time, VC has increased two classes for the project.

CcrvtrackCursorinfo

CcrystalReportViewer3

(figure 1)

Design the size of the main dialog box as needed and increase the Crystal Report Viewer Control control. ID is IDC_CRVIEWER1

And set its properties as required.

Then use the Class Wizard to associate a variable M_Crv1.

the fourth step:

Increase the COM interface object of Crystal Report, there are two methods, the first method, introduced by #import, slightly complicated.

Adoption of the second method is imported by the type library.

The specific method is as follows:

Add class / from type library in Class Wizard (ADD CLASS / FROM A TYPE LIBRARY) (Figure 2)

(figure 2)

Select file craxdrt.tlb. Generally in the C: / Program Files / Seagate Software / Crystal Reports / Developer Files / Include directory.

Then select the class we need, because the example only requires Ireport, Iapplication. Press CTRL to select this two items.

the fifth step:

Add header files in Demordcdlg.h files:

#include "craxdrt.h"

#include "comdef.h"

And Guid statement:

// the Guid for Crystal Report

Const CLSID CLSID_Application = {0xB4741FD0, 0X45A6, 0X11D1, {0XAB, 0XEC, 0x00, 0XA0, 0XC9, 0X27, 0X4B, 0X91}}

const IID IID_IApplication = {0x0bac5cf2,0x44c9,0x11d1, {0xab, 0xec, 0x00,0xa0,0xc9,0x27,0x4b, 0x91}}; const CLSID CLSID_ReportObjects = {0xb4741e60,0x45a6,0x11d1, {0xab, 0xec, 0x00,0xa0, 0xc9, 0x27, 0x4b, 0x91}};

Const IID IID_IREPORTOBJECTS = {0x0BAC59B2, 0X44C9, 0X11D1, {0XAB, 0XEC, 0x00, 0XA0, 0XC9, 0X27, 0X4B, 0X91}}

Step 6:

The main code part:

Add two protected type member variables for cdemordcdlg

Iapplication M_Application;

Ireport m_report;

Join our main statement in Bool CDemordcdlg :: OnItDialog ()

CString StrtemplatePath;

StrtemplatePath = AppPath () "Demordc.rpt";

Variant Dummy;

Variantinit (& DUMMY);

Dummy.vt = vt_empty;

// Specify the path to the report you want to print

_BSTR_T REPORTPATH ​​(StrtemplatePath);

m_application.created ;;;;;;;;;;;;;;

M_report = m_application.openreport (ReportPath, Dummy);

m_crv1.setReportSource (M_Report);

m_crv1.viewReport ();

Step 7:

Increase virtual functions Postncdestroy

In these Realse M_Application and M_Report;

Compile OK.

Download Sample Project Document Demordc.zip, 46K (Win2000 VC6)

The above, just describes the calling method in the Crystal Report (RDC8) in the VC6 environment. If you want to make a relatively perfect report, you have to work hard. I hope to help the developers of VC.

In the imperfection of this article, please also criticize the correct.

Email: jaesyinfo@163.net

http://jaesyinfo.51.net