Consultor Eletrônico



Kbase 22027: ACTIVEX: How To Use Crystal Reports Viewer -- Sample Program
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/15/2002
SUMMARY:

This Solution demonstrates how to open a Crystal Reports report by using the Crystal Reports Viewer OCX control.

EXPLANATION:

Further information can be found by opening the following files in the Progress COM Object Viewer tool (Tools -> PRO*Tools):

- crviewer.dll
- craxdrt.dll

SOLUTION:

This sample was tested with Crystal Reports 8.5.

1) Insert the Crystal Report Viewer Control into a window.

2) Add a button and copy the following code into the CHOOSE trigger.

DEFINE VARIABLE crApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE crReport AS COM-HANDLE NO-UNDO.

CREATE "CrystalRuntime.Application" crApplication.
CREATE "CrystalRuntime.Report" crReport.

/* Set the report object */
crReport = crApplication:OpenReport("W:\report1.rpt").

/* Enables the CRViewer's Navigation Controls */
chCtrlFrame:CRViewer:EnableNavigationControls = TRUE.

/* Enables the CRViewer's Export button */
chCtrlFrame:CRViewer:EnableExportButton = TRUE.

/* Disables the CRViewer's Search control */
chCtrlFrame:CRViewer:EnableSearchControl = FALSE.

/* Set the report source */
chCtrlFrame:CRViewer:ReportSource = crReport.

/* View the report */
chCtrlFrame:CRViewer:ViewReport().

RELEASE OBJECT crApplication.
RELEASE OBJECT crReport.

NOTE: Ensure that all COM-HANDLE variables are released. Otherwise 2
problems might occur:

-- When closing the report:
The temporary files generated by Crystal Reports will not be
deleted. They should be in the directory specified by the TMP
environment variable.

-- When closing the Progress session:
The Prowin32.exe process will use 100% of the CPU until an
"Application Error" message appears.
The exact error message is:

OleMainThreadWndName: prowin32.exe - Application Error


References to Written Documentation:

Progress Knowledge Base Solution 20334, "ACTIVEX - How To View a Crystal Reports Report"