Register_Object oCrystalReportTest Use cCrystal.pkg Use cRegistry.pkg Use StatPnl.pkg #IFDEF GET_SHELLEXECUTE #ELSE External_Function ShellExecute "ShellExecuteA" Shell32.Dll ; Handle hwnd ; String sOperation ; String sFile ; String sParameters ; String sDirectory ; Integer nShowCmd ; Returns VOID_TYPE #ENDIF Use Windows.pkg Use cRichEdit.pkg Use cCrystal.pkg Object oCheckForCrystal is a ModalPanel // Messages for the Status_Panel object Procedure SetStatusMsg String sMsg Send Initialize_StatusPanel of Status_Panel "Crystal Reports" "" sMsg End_Procedure Procedure PopupStatusPanel Send Start_StatusPanel of Status_Panel End_Procedure Procedure DeactivateStatusPanel Send Stop_StatusPanel of Status_Panel End_Procedure // Property to hold if Crystal Reports RDC components are loaded Property Boolean pbCrystalLoaded False // Property to hold if Crystal Reports XI CDO can be loaded Property Boolean pbCrystalCDOLoaded False // Property to hold if Crystal Reports Connectivity Kit DLLs are present Property Boolean pbCrystalCKPresent False // Check if Crystal Reports RDC components can be loaded Function CheckForCrystal Handle hoCrystalReport Returns Boolean Boolean bCrystalLoaded Handle hoApplicationObject String sError Get pbCrystalLoaded to bCrystalLoaded If (not (bCrystalLoaded)) Begin Send SetStatusMsg "Loading Crystal RDC Components. Please wait..." Send PopupStatusPanel Get ApplicationObject of hoCrystalReport to hoApplicationObject Send DeactivateStatusPanel If (not (hoApplicationObject)) Begin Move "Could not connect to the Crystal RDC Application Object." to sError Error DFERR_CRYSTAL_REPORT sError End Else Begin Move True to bCrystalLoaded End End Set pbCrystalLoaded to bCrystalLoaded Function_Return bCrystalLoaded End_Function // Check if Crystal Reports CDO component can be created Function CheckForCDO Handle hoCRReport Returns Boolean Boolean bCDOFunctional Boolean bErrorState String sError Handle hoCDO // Try to create CDO object Get Create U_cCrystalCrystalComObject to hoCDO Send CreateComObject of hoCDO Get IsComObjectCreated of hoCDO to bCDOFunctional If (not (bCDOFunctional)) Begin Move "Error creating Crystal Reports CDO object." to sError Move (sError * "Make sure Crystal Data Object is installed and properly registered on your machine.") to sError Error DFERR_CRYSTAL_REPORT sError End Set pbCrystalCDOLoaded to bCDOFunctional Send Destroy of hoCDO Function_Return bCDOFunctional End_Function // Check if Crystal Reports Connectivity Kit files are in the expected location Function CheckCKFiles Handle hoRegistry Returns Boolean Boolean bCrystalCKFound Boolean bDriverDLLExists bCrdbDLLExists String sCommonDir sDriverDLL sCrdbDLL If (ValueExists(hoRegistry, "CommonFiles")) Begin Get ReadString of hoRegistry "CommonFiles" to sCommonDir If (Right(sCommonDir, 1) <> "\") Begin Move (sCommonDir - "\") to sCommonDir End Move (sCommonDir - "p2bdfapi.dll") to sDriverDLL Move (sCommonDir - "crdb_p2bdfapi.dll") to sCrdbDLL File_Exist sDriverDLL bDriverDLLExists File_Exist sCrdbDLL bCrdbDLLExists Move (bDriverDLLExists And bCrdbDLLExists) to bCrystalCKFound End Function_Return bCrystalCKFound End_Function // Check if Crystal Reports Connectivity Kit is present in the development environment Function CheckForCrystalCK Returns Boolean Boolean bOpen bCrystalCKFound Handle hoRegistry String sError Move False to bCrystalCKFound Get create U_cRegistry to hoRegistry Set phRootKey of hoRegistry to HKEY_LOCAL_MACHINE Get OpenKey of hoRegistry "SOFTWARE\Business Objects\Suite 11.0\Crystal Reports" to bOpen If (bOpen) Begin Get CheckCKFiles hoRegistry to bCrystalCKFound Send CloseKey of hoRegistry End If (not (bCrystalCKFound)) Begin Move "Crystal Reports Connectivity Kit could not be found in the Crystal Reports XI CommonFiles directory." to sError Error DFERR_CRYSTAL_REPORT sError End Set pbCrystalCKPresent to bCrystalCKFound Send Destroy of hoRegistry Function_Return bCrystalCKFound End_Function // Check if all Crystal Reports pieces necessary for the report to run can be used Function CheckCrystalEnvironment Returns Boolean Boolean bCR bCDO bCK Get pbCrystalLoaded to bCR Get pbCrystalCDOLoaded to bCDO Get pbCrystalCKPresent to bCK If (not(bCR)) Begin Get CheckForCrystal oCrystalReportTest to bCR Send UpdateCRStatus of oCheckEnvironmentGroup bCR End If (not(bCDO)) Begin Get CheckForCDO oCrystalReportTest to bCDO Send UpdateCDOStatus of oCheckEnvironmentGroup bCDO End If (not(bCK)) Begin Get CheckForCrystalCK to bCK Send UpdateCKStatus of oCheckEnvironmentGroup bCK End Function_Return (bCR and bCDO and bCK) End_Function // Display the dialog with information on tests performed Procedure DisplayDialog Send Popup_Modal End_Procedure Set Label to "Crystal Reports Test Information" Set Location to 1 59 Set Size to 358 310 Set piMinSize to 358 310 Object oCloseBtn is a Button Set Label to "&Close" Set Size to 14 82 Set Location to 321 211 Procedure OnClick Send Close_Panel End_Procedure // OnClick End_Object // oCloseBtn Object oIntroduction is a cRichEdit Set Size to 212 277 Set Location to 9 15 Set Color to clWhite Set TextColor to clBlue Set Read_Only_State to True Procedure Page Boolean bPageObject Forward Send Page bPageObject If (bPageObject) Begin Send Delete_Data Send AppendText "This sample uses reports built with Crystal Reports. In order to run such reports " Send AppendText "you need to have " Set pbBold to True Send AppendText "Crystal Reports for DataFlex installed. " Set pbBold to False Send AppendText "Also, for the reports using Crystal Data Objects (CDO), " Send AppendTextLn "CDO needs to be installed and properly registered on this machine." Send AppendTextLn "" Set pbBold to True Send AppendText "Note that the reports in this sample will only work if all the above items are available and can be used on your machine. " Send AppendTextLn "This dialog is being displayed because at least one of the tests for Crystal failed." Set pbBold to False Send AppendTextLn "" Send AppendTextLn "The following links will help you correcting your environment: " Send AppendTextLn "" Send AppendTextLn "ERROR: Could not connect to the Crystal RDC Application Object http://www.dataaccess.com/kbasepublic/kbprint.asp?ArticleID=2169" Send AppendTextLn "" Send AppendTextLn "ERROR: 'Unable to instantiate COM Object.' when running a report http://www.dataaccess.com/kbasepublic/kbprint.asp?ArticleID=2183" Send AppendTextLn "" Send AppendTextLn "INFO: Running Reports from Crystal XI from Visual DataFlex Application http://www.dataaccess.com/kbasepublic/kbprint.asp?ArticleId=2161" Send AppendTextLn "" Send AppendTextLn "Data Access Worldwide Knowledge Base -- http://www.dataaccess.com/KBase" Send AppendTextLn "" Send AppendText "If you need to buy Crystal Reports for DataFlex or need more information on the product, visit " Set pbBold to True Send AppendTextLn "http://www.dataaccess.com/Crystal" Set pbBold to False Send Beginning_of_Data End End_Procedure // Page Procedure OnLinkClicked Integer iPositionStart Integer iPositionEnd Handle hInstance hWnd String sLinkText Get TextRange iPositionStart iPositionEnd to sLinkText If (sLinkText <> "") Begin Get Window_Handle to hWnd Move (ShellExecute (hWnd, "open", (Trim (sLinkText)), '', '', 1)) to hInstance End End_Procedure // OnLinkClicked End_Object // oIntroduction Object oCheckEnvironmentGroup is a Group Set Size to 88 277 Set Location to 228 16 Set Label to "Results of Tests Performed" Object oCR is a Form Set Size to 14 118 Set Location to 18 118 Set Color to clBtnFace Set Enabled_State to FALSE Set Form_Justification_Mode Item 0 to Form_DisplayCenter Procedure Activating Set Value to "Crystal Reports RDC Components" Set Entry_State to False End_Procedure End_Object // oCR Object oCDO is a Form Set Size to 14 118 Set Location to 42 118 Set Color to clBtnFace Set Enabled_State to False Set Form_Justification_Mode Item 0 to Form_DisplayCenter Procedure Activating Set Value to "Crystal Reports CDO" Set Entry_State to False End_Procedure End_Object // oCDO Object oCK is a Form Set Size to 14 118 Set Location to 65 118 Set Color to clBtnFace Set Enabled_State to False Set Form_Justification_Mode 0 to FORM_DISPLAYCENTER Procedure Activating Set Value to "Crystal Reports Connectivity Kit" Set Entry_State to False End_Procedure End_Object // oCK Object oCRComponentStatus is a Textbox Set Label to "Untested" Set Auto_Size_State to False Set TextColor to clMaroon Set Location to 18 28 Set Size to 10 73 Set TypeFace to "MS Sans Serif" End_Object // oCRComponentStatus Object oCDOStatus is a Textbox Set Label to "Untested" Set Auto_Size_State to False Set TextColor to clMaroon Set Location to 42 28 Set Size to 10 73 Set TypeFace to "MS Sans Serif" End_Object // oCDOStatus Object oCKStatus is a Textbox Set Label to "Untested" Set Auto_Size_State to False Set TextColor to clMaroon Set Location to 66 28 Set Size to 10 73 Set TypeFace to "MS Sans Serif" End_Object // oCKStatus // Reset Crystal Reports status text to Untested Procedure ResetCRStatus Set TextColor of oCRComponentStatus to clMaroon Set Value of oCRComponentStatus to "Untested" End_Procedure // Set the status text of Crystal Reports according to result passed as parameter Procedure UpdateCRStatus Boolean bOK String sStatus If (bOK) Begin Set TextColor of oCRComponentStatus to clBlue Move "Passed" to sStatus End Else Begin Set TextColor of oCRComponentStatus to clRed Move "Failed" to sStatus End Set Value of oCRComponentStatus to sStatus End_Procedure // Reset CDO status text to Untested Procedure ResetCDOStatus Set TextColor of oCDOStatus to clMaroon Set Value of oCDOStatus to "Untested" End_Procedure // Set the status text of CDO according to result passed as parameter Procedure UpdateCDOStatus Boolean bOK String sStatus If (bOK) Begin Set TextColor of oCDOStatus to clBlue Move "Passed" to sStatus End Else Begin Set TextColor of oCDOStatus to clRed Move "Failed" to sStatus End Set Value of oCDOStatus to sStatus End_Procedure // Reset Conectivity Kit status text to Untested Procedure ResetCKStatus Set TextColor of oCKStatus to clMaroon Set Value of oCKStatus to "Untested" End_Procedure // Set the status text of Connectivity Kit according to result passed as parameter Procedure UpdateCKStatus Boolean bOK String sStatus If (bOK) Begin Set TextColor of oCKStatus to clBlue Move "Passed" to sStatus End Else Begin Set TextColor of oCKStatus to clRed Move "Failed" to sStatus End Set Value of oCKStatus to sStatus End_Procedure // Reset all status texts to Untested Procedure ResetStatuses Send ResetCRStatus Send ResetCDOStatus Send ResetCKStatus End_Procedure End_Object // oCheckEnvironmentGroup Object oCrystalReportTest is a cCrystal // This object is to be used when checking for Crystal from the buttons on this dialog End_Object // oCrystalReportTest End_Object // oCheckForCrystal