Use DfRptVw.pkg Use Crystal\CheckForCrystal.dg Use dfrptvw.pkg Use Windows.pkg Use DfLine.Pkg Use cCrystalActiveXReportViewer.pkg Use File_dlg.Pkg Use cCrystal.pkg DEFERRED_VIEW Activate_oReportPreviewCR FOR ; ; Object oReportPreviewCR is a ReportView // Handle to ActiveX previewer Property Handle phoActiveXReportViewer 0 Set Border_Style to Border_Thick Set Label to "Crystal Reports Previewer" Set Location to 6 6 Set Size to 269 398 Set piMinSize to 269 398 Object oReportForm is a Form Set Label to "Crystal Report:" Set Size to 13 320 Set Location to 10 61 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Prompt_Button_Mode to pb_PromptOn // Send when the prompt key is pressed, start selection list Procedure Prompt Integer iSelected iNumPaths String sSelectedFile String sDataDir Get psDataPath of (phoWorkspace(ghoApplication)) to sDataDir Get CountOfPaths of (phoWorkspace(ghoApplication)) sDataDir to iNumPaths If (iNumPaths > 1) Get PathAtIndex of (phoWorkspace(ghoApplication)) sDataDir 1 to sDataDir Set Initial_Folder of oNewDialog to sDataDir // Start the save as dialog Get Show_Dialog of oNewDialog to iSelected If iSelected Begin Get File_Name of oNewDialog to sSelectedFile Set Value to sSelectedFile End End_Procedure // Prompt End_Object // oReportForm Object oLineControl1 is a LineControl Set Size to 2 376 Set Location to 28 8 Set peAnchors to anTopLeftRight End_Object // oLineControl1 Object oCrystalActivexReportViewer1 is a cCrystalActiveXReportViewer Set Size to 185 375 Set Location to 34 8 Set peAnchors to anAll Procedure OnCreate Forward Send OnCreate Set ComDisplayToolbar to True Set ComDisplayTabs to False Set ComDisplayGroupTree to False Set ComEnableGroupTree to False Set ComEnablePrintButton to True Set ComEnableCloseButton to False Set ComEnableRefreshButton to False Set ComEnableExportButton to True Set ComEnableSearchExpertButton to True Set ComEnableHelpButton to False Set ComEnableZoomControl to True Set ComEnableProgressControl to True Set ComEnableSearchControl to True Set ComEnableNavigationControls to True Set ComEnableDrillDown to False Set ComEnableAnimationCtrl to True Set ComEnableSelectExpertButton to False Set ComLaunchHTTPHyperlinksInNewBrowser to True End_Procedure // OnCreate End_Object // oCrystalActivexReportViewer1 Object oNewDialog is a OpenDialog Set Dialog_Caption to "Customer report export to disk, give file name" Set Filter_String to "Crystal Report (*.rpt)|*.rpt|All Files|*.*" Set HideReadOnly_State to True End_Object // oNewDialog Object oOkButton is a Button Set Label to "Run Report" Set Size to 14 51 Set Location to 226 280 Set peAnchors to anBottomRight Set Default_State to True Procedure OnClick Boolean bReportOK bCrystalOK String sReportName Get Value of oReportForm to sReportName // Check if the report name was specified and report actually exists Get ValidateReportName sReportName to bReportOK If (bReportOK) Begin Get CheckCrystalEnvironment of oCheckForCrystal to bCrystalOK If (bCrystalOK) Begin Set psReportName of oCrystalReport1 to sReportName Send RunReport of oCrystalReport1 End Else Begin Send DisplayDialog of oCheckForCrystal End End Else Begin Send activate of oReportForm End End_Procedure // OnClick End_Object // oOkButton Object oCancelButton is a Button Set Label to "Cancel" Set Location to 226 334 Set peAnchors to anBottomRight Procedure OnClick Send Request_Cancel End_Procedure // OnClick End_Object // oCancelButton Object oCrystalReport1 is a cCrystal Set psReportName to "" // procedure is called when report is sent to previewer Procedure OnDisplayReport Handle hoReport Forward Send OnDisplayReport hoReport // This assigns the preview object so we can use our custom previewer Send AssignPreviewObject of hoReport oReportPreviewCR End_Procedure // OnDisplayReport End_Object // oCrystalReport1 // set property to activeX preview object Set phoActiveXReportViewer to oCrystalActiveXReportViewer1 // Message received by CrystalReport to display the report. Procedure DisplayReport Handle hoReport Handle hoViewer Variant vViewer Get phoActiveXReportViewer to hoViewer If (hoViewer) Begin Get pvComObject of hoReport to vViewer Set ComReportSource of hoViewer to vViewer Send ComViewReport of hoViewer Send ComZoom of hoViewer 100 End End_Procedure // DisplayReport Function ReportExists String sRPTName Returns Boolean Boolean bReportExists // Check if the report actually exists File_Exist sRPTName bReportExists Function_Return bReportExists End_Function Function ValidateReportName String sReportName Returns Boolean Boolean bReportNameOK Move False to bReportNameOK If (sReportName="") Begin Send Info_Box "Select or specify a report." "Report Information" End Else Begin Get ReportExists sReportName to bReportNameOK If (not(bReportNameOK)) Begin Send Info_Box ("The report file " + sReportName + " does not exist. Select or specify another one.") "Report Information" End End Function_Return bReportNameOK End_Function CD_End_Object // oReportPreviewCR