Module CheckForFlex2Crystal.dg

     1//*************************************************************************
     2//*                                                                       *
     3//*  Confidential Trade Secret.                                           *
     4//*  Copyright (c) 2011-2012 Mertech Data Systems Inc, Miami Florida      *
     5//*  All rights reserved.                                                 *
     6//*  DataFlex is a registered trademark of Data Access Corporation.       *
     7//*                                                                       *
     8//*************************************************************************
     9Use Windows.pkg
    10Use cRichEdit.pkg
    11Use cFlex2Crystal.pkg
    12Use cRegistry.pkg
    13
    14Register_Object oCrystalReportTest
    15
    16Object oCheckForFlex2Crystal is a ModalPanel
    17    Set Size to 251 259
    18    Set Label to "Flex2Crystal Test Information"
    19    Set piMinSize to 89 211
    20    Set Location to 3 4
    21    Set Border_Style to Border_Thick
    22    Property Boolean pbFlex2CrystalLoaded False
    23    Property Boolean pbCrystalPresent False
    24
    25    Object oOK_Btn is a Button
    26        Set Label    to "&OK"
    27        Set Location to 233 104
    28        Set peAnchors To anBottomRight
    29
    30        Procedure OnClick
    31            Send Close_Panel
    32        End_Procedure
    33
    34    End_Object
    35
    36    Object oOutput is a cRichEdit
    37        Set Size to 129 248
    38        Set Location to 4 5
    39        Set peAnchors to anAll
    40
    41        Procedure Page Integer bPageObject
    42            Forward Send Page bPageObject
    43            
    44            If (bPageObject) Begin
    45                Send Delete_Data
    46                If (not(pbFlex2CrystalLoaded(Self))) Begin
    47                    Send AppendTextLn "The COM interface for Flex2Crystal could not be loaded. Please make sure the Flex2Crystal control is properly registered."
    48                End
    49                If (not(pbCrystalPresent(Self))) Begin
    50                    Send AppendTextLn "It does not appear that SAP Crystal Reports 2011 is installed on this PC.  The registry entries for Crystal Reports are missing."
    51                End
    52            End
    53        End_Procedure
    54
    55    End_Object
    56
    57    On_Key Key_Alt+Key_O Send KeyAction of oOK_Btn
    58
    59    Function CheckForFlex2Crystal Handle hoCrystalReport Returns Boolean
    60        Handle hoAppObj
    61        Boolean bF2CLoaded
    62        
    63        Get pbFlex2CrystalLoaded to bF2CLoaded
    64        If (not(bF2CLoaded)) Begin
    65            Get ApplicationObject of hoCrystalReport to hoAppObj
    66            If (not(hoAppObj)) Begin
    67                Error DFERR_CRYSTAL_REPORT "Couldn't Load Application Object"
    68            End
    69            Else Move True to bF2CLoaded
    70        End
    71        
    72        Set pbFlex2CrystalLoaded to bF2CLoaded
    73        Function_Return bF2CLoaded
    74    End_Function
    75    
    76    Function CheckForCrystal Returns Boolean
    77        Handle hoRegistry
    78        Boolean bHasCrystal bCrystalPresent
    79        
    80        Get pbCrystalPresent to bCrystalPresent
    81        If (not(bCrystalPresent)) Begin
    82            Get Create U_cRegistry to hoRegistry
    83            Set pfAccessRights of hoRegistry to KEY_READ
    84            
    85            Set phRootKey of hoRegistry to HKEY_LOCAL_MACHINE
    86            Get OpenKey of hoRegistry "SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports" to bHasCrystal
    87            If (bHasCrystal) Begin
    88                Move bHasCrystal to bCrystalPresent
    89                Send CloseKey of hoRegistry
    90            End
    91            Send Destroy of hoRegistry
    92        End
    93        
    94        Set pbCrystalPresent to bCrystalPresent
    95        Function_Return bCrystalPresent
    96    End_Function
    97    
    98    Function CheckCrystalEnvironment Returns Boolean
    99        Boolean bCrystal bF2C bCDO
   100        
   101        Get CheckForFlex2Crystal oCrystalReportTest to bF2C
   102        Get CheckForCrystal oCrystalReportTest to bCrystal
   103        
   104        Function_Return (bF2C and bCrystal)
   105    End_Function
   106
   107    Procedure DisplayDialog
   108        Send Popup_Modal
   109    End_Procedure
   110
   111    Object oCrystalReportTest is a cFlex2Crystal
   112    End_Object    // oCrystalReportTest
   113    
   114End_Object