home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / crystal / extras / crpedemo / main.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-12-15  |  53.9 KB  |  1,523 lines

  1. VERSION 2.00
  2. Begin MDIForm Main 
  3.    Caption         =   "CRPEDemo "
  4.    ClientHeight    =   5235
  5.    ClientLeft      =   1065
  6.    ClientTop       =   1965
  7.    ClientWidth     =   10215
  8.    Height          =   5925
  9.    Icon            =   MAIN.FRX:0000
  10.    Left            =   1005
  11.    LinkTopic       =   "Main"
  12.    Top             =   1335
  13.    Width           =   10335
  14.    WindowState     =   2  'Maximized
  15.    Begin SSPanel Panel3D1 
  16.       Align           =   2  'Align Bottom
  17.       Alignment       =   1  'Left Justify - MIDDLE
  18.       BackColor       =   &H00C0C0C0&
  19.       BevelInner      =   1  'Inset
  20.       BevelOuter      =   0  'None
  21.       BevelWidth      =   2
  22.       BorderWidth     =   2
  23.       Font3D          =   0  'None
  24.       Height          =   690
  25.       Left            =   0
  26.       TabIndex        =   2
  27.       Top             =   4065
  28.       Visible         =   0   'False
  29.       Width           =   10215
  30.       Begin SSCommand Command3D17 
  31.          Caption         =   "Close"
  32.          Font3D          =   0  'None
  33.          Height          =   375
  34.          Left            =   2760
  35.          TabIndex        =   18
  36.          Top             =   180
  37.          Visible         =   0   'False
  38.          Width           =   795
  39.       End
  40.       Begin SSCommand Command3D16 
  41.          Font3D          =   0  'None
  42.          Height          =   375
  43.          Left            =   2190
  44.          Picture         =   MAIN.FRX:0302
  45.          TabIndex        =   16
  46.          Top             =   180
  47.          Visible         =   0   'False
  48.          Width           =   405
  49.       End
  50.       Begin SSCommand Command3D15 
  51.          Font3D          =   0  'None
  52.          Height          =   375
  53.          Left            =   1740
  54.          Picture         =   MAIN.FRX:047A
  55.          TabIndex        =   15
  56.          Top             =   180
  57.          Visible         =   0   'False
  58.          Width           =   405
  59.       End
  60.       Begin SSCommand Command3D14 
  61.          Font3D          =   0  'None
  62.          Height          =   375
  63.          Left            =   900
  64.          Picture         =   MAIN.FRX:05EC
  65.          TabIndex        =   14
  66.          Top             =   180
  67.          Visible         =   0   'False
  68.          Width           =   405
  69.       End
  70.       Begin SSCommand Command3D13 
  71.          Font3D          =   0  'None
  72.          Height          =   375
  73.          Left            =   450
  74.          Picture         =   MAIN.FRX:0766
  75.          TabIndex        =   13
  76.          Top             =   180
  77.          Visible         =   0   'False
  78.          Width           =   405
  79.       End
  80.    End
  81.    Begin SSPanel ToolBar 
  82.       Align           =   1  'Align Top
  83.       BackColor       =   &H00C0C0C0&
  84.       Font3D          =   0  'None
  85.       Height          =   555
  86.       Left            =   0
  87.       TabIndex        =   1
  88.       Top             =   0
  89.       Width           =   10215
  90.       Begin SSCommand SQLButton 
  91.          Enabled         =   0   'False
  92.          Font3D          =   0  'None
  93.          Height          =   375
  94.          Left            =   5280
  95.          Picture         =   MAIN.FRX:08E0
  96.          TabIndex        =   20
  97.          Top             =   90
  98.          Width           =   405
  99.       End
  100.       Begin Timer Timer1 
  101.          Left            =   9060
  102.          Top             =   90
  103.       End
  104.       Begin SSCommand GroupCondButton 
  105.          Enabled         =   0   'False
  106.          Font3D          =   0  'None
  107.          Height          =   375
  108.          Left            =   3300
  109.          Picture         =   MAIN.FRX:0ACA
  110.          TabIndex        =   19
  111.          Top             =   90
  112.          Width           =   405
  113.       End
  114.       Begin SSCommand SortButton 
  115.          Enabled         =   0   'False
  116.          Font3D          =   0  'None
  117.          Height          =   375
  118.          Left            =   3810
  119.          Picture         =   MAIN.FRX:0C4C
  120.          TabIndex        =   17
  121.          Top             =   90
  122.          Width           =   405
  123.       End
  124.       Begin SSCommand PrintButton 
  125.          Enabled         =   0   'False
  126.          Font3D          =   0  'None
  127.          Height          =   375
  128.          Left            =   1530
  129.          Picture         =   MAIN.FRX:0E36
  130.          TabIndex        =   12
  131.          Top             =   90
  132.          Width           =   405
  133.       End
  134.       Begin SSCommand OpenJobbutton 
  135.          Enabled         =   0   'False
  136.          Font3D          =   0  'None
  137.          Height          =   375
  138.          Left            =   600
  139.          Picture         =   MAIN.FRX:0FB8
  140.          TabIndex        =   11
  141.          Top             =   90
  142.          Width           =   405
  143.       End
  144.       Begin SSCommand HelpButton 
  145.          Font3D          =   0  'None
  146.          Height          =   375
  147.          Left            =   7410
  148.          Picture         =   MAIN.FRX:113A
  149.          TabIndex        =   10
  150.          Top             =   90
  151.          Width           =   405
  152.       End
  153.       Begin SSCommand SelectionButton 
  154.          Enabled         =   0   'False
  155.          Font3D          =   0  'None
  156.          Height          =   375
  157.          Left            =   4740
  158.          Picture         =   MAIN.FRX:12BC
  159.          TabIndex        =   9
  160.          Top             =   90
  161.          Width           =   405
  162.       End
  163.       Begin SSCommand Previewbutton 
  164.          Enabled         =   0   'False
  165.          Font3D          =   0  'None
  166.          Height          =   375
  167.          Left            =   1110
  168.          Picture         =   MAIN.FRX:15BE
  169.          TabIndex        =   8
  170.          Top             =   90
  171.          Width           =   405
  172.       End
  173.       Begin SSCommand Graphbutton 
  174.          Enabled         =   0   'False
  175.          Font3D          =   0  'None
  176.          Height          =   375
  177.          Left            =   2880
  178.          Picture         =   MAIN.FRX:18C0
  179.          TabIndex        =   7
  180.          Top             =   90
  181.          Width           =   405
  182.       End
  183.       Begin SSCommand FormulaButton 
  184.          Enabled         =   0   'False
  185.          Font3D          =   0  'None
  186.          Height          =   375
  187.          Left            =   4320
  188.          Picture         =   MAIN.FRX:1A9C
  189.          TabIndex        =   6
  190.          Top             =   90
  191.          Width           =   405
  192.       End
  193.       Begin SSCommand FormatButton 
  194.          Enabled         =   0   'False
  195.          Font3D          =   0  'None
  196.          Height          =   375
  197.          Left            =   2460
  198.          Picture         =   MAIN.FRX:1C70
  199.          TabIndex        =   5
  200.          Top             =   90
  201.          Width           =   405
  202.       End
  203.       Begin SSCommand ExportButton 
  204.          Enabled         =   0   'False
  205.          Font3D          =   0  'None
  206.          Height          =   375
  207.          Left            =   1950
  208.          Picture         =   MAIN.FRX:1DFC
  209.          TabIndex        =   4
  210.          Top             =   90
  211.          Width           =   405
  212.       End
  213.       Begin SSCommand OpenEngButton 
  214.          Font3D          =   0  'None
  215.          Height          =   375
  216.          Left            =   180
  217.          Picture         =   MAIN.FRX:20FE
  218.          TabIndex        =   3
  219.          Top             =   90
  220.          Width           =   405
  221.       End
  222.       Begin CommonDialog CMDialog1 
  223.          DefaultExt      =   "*.rpt"
  224.          DialogTitle     =   "Open Report"
  225.          Filter          =   "Crystal Report(*.rpt)|*.rpt"
  226.          Left            =   9540
  227.          Top             =   45
  228.       End
  229.    End
  230.    Begin SSPanel StatusBar 
  231.       Align           =   2  'Align Bottom
  232.       Alignment       =   1  'Left Justify - MIDDLE
  233.       BackColor       =   &H00C0C0C0&
  234.       BevelInner      =   1  'Inset
  235.       BevelOuter      =   0  'None
  236.       BevelWidth      =   2
  237.       BorderWidth     =   2
  238.       Caption         =   " Ready"
  239.       Font3D          =   0  'None
  240.       FontBold        =   0   'False
  241.       FontItalic      =   0   'False
  242.       FontName        =   "Arial"
  243.       FontSize        =   9
  244.       FontStrikethru  =   0   'False
  245.       FontUnderline   =   0   'False
  246.       Height          =   480
  247.       Left            =   0
  248.       TabIndex        =   0
  249.       Top             =   4755
  250.       Width           =   10215
  251.       Begin Line Line2 
  252.          BorderColor     =   &H00FFFFFF&
  253.          X1              =   0
  254.          X2              =   7350
  255.          Y1              =   30
  256.          Y2              =   30
  257.       End
  258.       Begin Line Line1 
  259.          BorderColor     =   &H00000000&
  260.          X1              =   0
  261.          X2              =   7350
  262.          Y1              =   15
  263.          Y2              =   15
  264.       End
  265.    End
  266.    Begin Menu MenuFile 
  267.       Caption         =   "&File"
  268.       Begin Menu MenuFileNew 
  269.          Caption         =   "&New"
  270.       End
  271.       Begin Menu MenuFileClose 
  272.          Caption         =   "&Close"
  273.          Enabled         =   0   'False
  274.       End
  275.       Begin Menu MenuFileSep1 
  276.          Caption         =   "-"
  277.       End
  278.       Begin Menu MenuFilePrint 
  279.          Caption         =   "&Print"
  280.          Enabled         =   0   'False
  281.          Begin Menu MenuFilePrinter 
  282.             Caption         =   "Printer"
  283.             Enabled         =   0   'False
  284.          End
  285.          Begin Menu MenuFileWindow 
  286.             Caption         =   "Window"
  287.          End
  288.          Begin Menu MenuFileFile 
  289.             Caption         =   "File"
  290.          End
  291.       End
  292.       Begin Menu MenuFileExport 
  293.          Caption         =   "&Export"
  294.          Enabled         =   0   'False
  295.       End
  296.       Begin Menu MenuFileSep2 
  297.          Caption         =   "-"
  298.       End
  299.       Begin Menu MenuFileExit 
  300.          Caption         =   "E&xit"
  301.       End
  302.    End
  303.    Begin Menu MenuEngine 
  304.       Caption         =   "&Engine"
  305.       Begin Menu MenuEngineOpen 
  306.          Caption         =   "&Open Engine"
  307.       End
  308.       Begin Menu MenuEngineClose 
  309.          Caption         =   "&Close Engine"
  310.          Enabled         =   0   'False
  311.       End
  312.       Begin Menu MenuEngineOpenJob 
  313.          Caption         =   "Open Print &Job"
  314.          Enabled         =   0   'False
  315.       End
  316.       Begin Menu MenuEngineCloseJob 
  317.          Caption         =   "C&lose Print Job"
  318.          Enabled         =   0   'False
  319.       End
  320.    End
  321.    Begin Menu MenuFormat 
  322.       Caption         =   "For&mat"
  323.       Begin Menu MenuFormatRptTitle 
  324.          Caption         =   "&Report Title"
  325.          Enabled         =   0   'False
  326.       End
  327.       Begin Menu MenuFormatSection 
  328.          Caption         =   "&Section"
  329.          Enabled         =   0   'False
  330.       End
  331.       Begin Menu MenuFormatGroupCond 
  332.          Caption         =   "Group &Condition"
  333.          Enabled         =   0   'False
  334.       End
  335.       Begin Menu MenuFormatGraph 
  336.          Caption         =   "&Graphing"
  337.          Enabled         =   0   'False
  338.       End
  339.    End
  340.    Begin Menu MenuFields 
  341.       Caption         =   "Sor&ting"
  342.       Begin Menu MenuFieldsRecordSortField 
  343.          Caption         =   "&Record Sort Fields"
  344.          Enabled         =   0   'False
  345.       End
  346.       Begin Menu MenuFieldsGroupSortFields 
  347.          Caption         =   "&Group Sort Fields"
  348.          Enabled         =   0   'False
  349.       End
  350.    End
  351.    Begin Menu MenuFormulas 
  352.       Caption         =   "Fo&rmula"
  353.       Begin Menu MenuFormulasSetFormula 
  354.          Caption         =   "&Formula"
  355.          Enabled         =   0   'False
  356.       End
  357.       Begin Menu MenuFormulasSetSelForm 
  358.          Caption         =   "&Selection Formula"
  359.          Enabled         =   0   'False
  360.       End
  361.       Begin Menu MenuFormulasGroupSel 
  362.          Caption         =   "&Group Selection Formula"
  363.          Enabled         =   0   'False
  364.       End
  365.    End
  366.    Begin Menu MenuDatabase 
  367.       Caption         =   "&Database"
  368.       Begin Menu MenuDBLocation 
  369.          Caption         =   "&Location"
  370.          Enabled         =   0   'False
  371.       End
  372.       Begin Menu MenuLogon 
  373.          Caption         =   "Log&on Server"
  374.          Enabled         =   0   'False
  375.       End
  376.       Begin Menu MenuLogoff 
  377.          Caption         =   "Logo&ff Server"
  378.          Enabled         =   0   'False
  379.       End
  380.       Begin Menu MenuLogonInfo 
  381.          Caption         =   "Logon &Info"
  382.          Enabled         =   0   'False
  383.       End
  384.       Begin Menu MenuSecurity 
  385.          Caption         =   "Access &Security"
  386.          Enabled         =   0   'False
  387.       End
  388.    End
  389.    Begin Menu MenuSQL 
  390.       Caption         =   "&SQL"
  391.       Begin Menu MenuSQLModify 
  392.          Caption         =   "&Modify SQL"
  393.          Enabled         =   0   'False
  394.       End
  395.       Begin Menu MenuSQLStoredProc 
  396.          Caption         =   "&Stored Procedure"
  397.          Enabled         =   0   'False
  398.       End
  399.    End
  400.    Begin Menu MenuWindow 
  401.       Caption         =   "&Window"
  402.       WindowList      =   -1  'True
  403.       Begin Menu MenuWindowCascade 
  404.          Caption         =   "&Cascade"
  405.          Enabled         =   0   'False
  406.       End
  407.       Begin Menu MenuWindowTileH 
  408.          Caption         =   "Tile &Horizontally"
  409.          Enabled         =   0   'False
  410.       End
  411.       Begin Menu MenuWindowTileV 
  412.          Caption         =   "&Tile Vertically"
  413.          Enabled         =   0   'False
  414.       End
  415.       Begin Menu MenuWindowArrange 
  416.          Caption         =   "&Arrange"
  417.          Enabled         =   0   'False
  418.       End
  419.    End
  420.    Begin Menu MenuHelp 
  421.       Caption         =   "&Help"
  422.       Begin Menu MenuHelpCRWHLP 
  423.          Caption         =   "&Crystal Reports Help"
  424.       End
  425.       Begin Menu MenuHelpWhere 
  426.          Caption         =   "&Included Print Engine Calls"
  427.       End
  428.       Begin Menu MenuHelpLine 
  429.          Caption         =   "-"
  430.       End
  431.       Begin Menu MenuHelpAbout 
  432.          Caption         =   "&About CRPEDemo..."
  433.       End
  434.    End
  435. ' Crystal.Vbx doesn't have an Align Property so The ToolBar
  436. ' is used as a container.
  437. ' The following Default Properties of Crystal.Vbx have been
  438. ' changed to:-
  439. '       WindowBorderStyle = 0 - None
  440. '       WindowControlBox = False
  441. '       WindowMaxButton = False
  442. '       WindowMinButton = False
  443. '       WindowLeft = 0      'so that the MoveWindow Function
  444. '       WindowTop = 0       'doesn't jerk the Crystal Window
  445. '                           'across the MDIChild Window.
  446. '--------------------------------------------------------------------
  447.  Dim DLLName As String * 20
  448. Sub Command1_Click ()
  449. End Sub
  450. Sub Command2_Click ()
  451.  If PEShowLastPage(Jobnum) = False Then
  452.    'RCode = PEGetErrorCode(Jobnum)
  453.    'MsgBox "PEShowPreviousPage = " + RCode
  454.  End If
  455. End Sub
  456. Sub Command3_Click ()
  457.  If PEShowPreviousPage(Jobnum) = False Then
  458.    'RCode = PEGetErrorCode(Jobnum)
  459.    'MsgBox "PEShowPreviousPage = " + RCode
  460.  End If
  461. End Sub
  462. Sub Command3D13_Click ()
  463.  If PEShowFirstPage(Jobnum) = False Then
  464.    'RCode = PEGetErrorCode(Jobnum)
  465.    'MsgBox "PEShowPreviousPage = " + RCode
  466.  End If
  467. End Sub
  468. Sub Command3D14_Click ()
  469.  If PEShowPreviousPage(Jobnum) = False Then
  470.    'RCode = PEGetErrorCode(Jobnum)
  471.    'MsgBox "PEShowPreviousPage = " + RCode
  472.  End If
  473. End Sub
  474. Sub Command3D15_Click ()
  475.  If PEShowNextPage(Jobnum) = False Then
  476.    'RCode = PEGetErrorCode(Jobnum)
  477.    'MsgBox "PEShowPreviousPage = " + RCode
  478.  End If
  479. End Sub
  480. Sub Command3D16_Click ()
  481.  If PEShowLastPage(Jobnum) = False Then
  482.    'RCode = PEGetErrorCode(Jobnum)
  483.    'MsgBox "PEShowPreviousPage = " + RCode
  484.  End If
  485. End Sub
  486. Sub Command3D17_Click ()
  487.     If Forms.Count > 1 Then
  488.         Unload ActiveForm
  489.         If Forms.Count = 1 Then
  490.             MenuFileClose.Enabled = False
  491.         End If
  492.     End If
  493. End Sub
  494. Sub Command4_Click ()
  495.  If PEShowNextPage(Jobnum) = False Then
  496.    'RCode = PEGetErrorCode(Jobnum)
  497.    'MsgBox "PEShowPreviousPage = " + RCode
  498.  End If
  499. End Sub
  500. Sub Command5_Click ()
  501.     If Forms.Count > 1 Then
  502.         Unload ActiveForm
  503.         If Forms.Count = 1 Then
  504.             MenuFileClose.Enabled = False
  505.         End If
  506.     End If
  507. End Sub
  508. Sub Command6_Click ()
  509.  If PEShowFirstPage(Jobnum) = False Then
  510.    'RCode = PEGetErrorCode(Jobnum)
  511.    'MsgBox "PEShowPreviousPage = " + RCode
  512.  End If
  513. End Sub
  514. Function exists (f As String) As Integer
  515. ' What follows is code for the exists function
  516. ' This function returns True if a given file exists, False otherwise
  517.   Dim n As Integer
  518.   On Error GoTo handler
  519.   n = FreeFile
  520.   ' Try to open file for input.  If successful, file exists
  521.   Open f For Input As #n
  522.   Close #n
  523.   exists = True
  524.   Exit Function
  525. handler:
  526.   ' If we get here the file does not exist
  527.   exists = False
  528.   Exit Function
  529. End Function
  530. Sub ExportButton_Click ()
  531. Dim ExportOptions As PEExportOptions
  532. 'Check to see if Resources are high enough to open the print engine
  533. 'Never let the user drop below 20% resources. If they do they ask them
  534. 'to exit the application, close other applications down, and try running
  535. 'CRPEDemo again
  536.     FreeRes = FreeResourcesAreAbove(20)
  537.     If FreeRes = False Then
  538.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  539.       Exit Sub
  540.     End If
  541. ExportOptions.StructSize = Len(ExportOptions)
  542. If PEGetExportOptions(Jobnum, ExportOptions) = False Then
  543.     RCode = GetErrorString(Jobnum)
  544.     MsgBox "PEGetExportOptions Error #: " + Str(ErrorCode) + " - " + RCode
  545.     Exit Sub
  546. End If
  547. If PEExportTo(Jobnum, ExportOptions) = False Then
  548.     RCode = GetErrorString(Jobnum)
  549.     MsgBox "PEExportTo Error #: " + Str(ErrorCode) + " - " + RCode
  550.     Exit Sub
  551. End If
  552. FreeRes = FreeResourcesAreAbove(20)
  553. If FreeRes = False Then
  554.   MsgBox "Your System Resources are below 20% Free, the job cannot be started! Please exit CRPEDemo, close some of your other Windows applications and try again."
  555.   Exit Sub
  556. End If
  557. If PEStartPrintJob(Jobnum, 1) = False Then
  558.     RCode = GetErrorString(Jobnum)
  559.     MsgBox "PEStartPrintJob Error #: " + Str(ErrorCode) + " - " + RCode
  560.     Exit Sub
  561. End If
  562. End Sub
  563. Sub FormatButton_Click ()
  564.   Section.Show 1
  565. End Sub
  566. Sub FormulaButton_Click ()
  567. SetFormula.Show 1
  568. End Sub
  569. Sub Graphbutton_Click ()
  570.   Graph.Show 1
  571. End Sub
  572. Sub GroupCondButton_Click ()
  573.  GroupCond.Show 1
  574. End Sub
  575. Sub HelpButton_Click ()
  576.   RCode = Shell("Winhelp c:\crw\crw.hlp", 3)
  577. End Sub
  578. Sub MDIForm_Load ()
  579.  ' Set timer for 1 second, and enable it.
  580.        Timer1.Interval = 1000
  581.        Timer1.Enabled = True
  582. End Sub
  583. Sub MDIForm_Resize ()
  584.     Line1.X2 = Me.ScaleWidth
  585.     Line2.X2 = Me.ScaleWidth
  586. End Sub
  587. Sub MDIForm_Unload (Cancel As Integer)
  588. On Error GoTo CRPEErr1
  589.     If Jobnum <> 0 Then
  590.        PEClosePrintJob (Jobnum)
  591.        Jobnum = 0
  592.     End If
  593.     PECloseEngine
  594.     Unload Me
  595.     End
  596. CRPEErr1:
  597. MsgBox "CRPE.DLL was not loaded. Please try running application again once the DLL is in your path."
  598. Exit Sub
  599. End Sub
  600. Sub MenuDBLocation_Click ()
  601.  Tablem.Show 1
  602. End Sub
  603. Sub MenuEditCopy_Click ()
  604.   MsgBox "Not Yet Implemented!"
  605. End Sub
  606. Sub MenuEditCut_Click ()
  607.  MsgBox "Not Yet Implemented!"
  608. End Sub
  609. Sub MenuEditPaste_Click ()
  610.    MsgBox "Not Yet Implemented!"
  611. End Sub
  612. Sub MenuEditUndo_Click ()
  613.  MsgBox "Not Yet Implemented!"
  614. End Sub
  615. Sub MenuEngineClose_Click ()
  616.   PECloseEngine
  617.   'Deactivate all menu items that were activated when opening
  618.   'the engine and the opening the print job
  619.             'Activate all menu items once job is opened
  620.             MenuEngineOpenJob.Enabled = False
  621.             MenuEngineClose.Enabled = False
  622.             MenuLogon.Enabled = False
  623.             MenuEngineOpen.Enabled = True
  624.             MenuFileNew.Enabled = True
  625.             MenuFilePrint.Enabled = False
  626.             MenuFilePrinter.Enabled = False
  627.             MenuFileWindow.Enabled = False
  628.             MenuFileFile.Enabled = False
  629.             MenuFileExport.Enabled = False
  630.             MenuEngineCloseJob.Enabled = False
  631.             MenuFormatRPTTitle.Enabled = False
  632.             MenuFormatSection.Enabled = False
  633.             MenuFormatGroupCond.Enabled = False
  634.             MenuFormatGraph.Enabled = False
  635.             MenuFieldsRecordSortField.Enabled = False
  636.             MenuFieldsGroupSortFields.Enabled = False
  637.             MenuFormulasSetFormula.Enabled = False
  638.             MenuFormulasSetSelForm.Enabled = False
  639.             MenuFormulasGroupSel.Enabled = False
  640.             MenuDBLocation.Enabled = False
  641.             MenuLogonInfo.Enabled = False
  642.             MenuSecurity.Enabled = False
  643.             MenuSQLModify.Enabled = False
  644.             MenuSQLStoredProc.Enabled = False
  645.             MenuWindowCascade.Enabled = False
  646.             MenuWindowTileH.Enabled = False
  647.             MenuWindowTileV.Enabled = False
  648.             MenuWindowArrange.Enabled = False
  649.             OpenEngButton.Enabled = True
  650.             OpenJobButton.Enabled = False
  651.             PreviewButton.Enabled = False
  652.             PrintButton.Enabled = False
  653.             SelectionButton.Enabled = False
  654.             SortButton.Enabled = False
  655.             GroupCondButton.Enabled = False
  656.             HelpButton.Enabled = True
  657.             GraphButton.Enabled = False
  658.             FormulaButton.Enabled = False
  659.             FormatButton.Enabled = False
  660.             ExportButton.Enabled = False
  661.             SQLButton.Enabled = False
  662.   Main!StatusBar.Caption = "The engine is now closed."
  663. End Sub
  664. Sub MenuEngineCloseJob_Click ()
  665.   PEClosePrintJob (Jobnum)
  666.   Jobnum = 0
  667. 'Deactivate all menu items that were active after
  668. 'opening the print job
  669.             MenuFileNew.Enabled = False
  670.             MenuFilePrint.Enabled = False
  671.             MenuFilePrinter.Enabled = False
  672.             MenuFileWindow.Enabled = False
  673.             MenuFileFile.Enabled = False
  674.             MenuFileExport.Enabled = False
  675.             MenuEngineCloseJob.Enabled = False
  676.             MenuFormatRPTTitle.Enabled = False
  677.             MenuFormatSection.Enabled = False
  678.             MenuFormatGroupCond.Enabled = False
  679.             MenuFormatGraph.Enabled = False
  680.             MenuFieldsRecordSortField.Enabled = False
  681.             MenuFieldsGroupSortFields.Enabled = False
  682.             MenuFormulasSetFormula.Enabled = False
  683.             MenuFormulasSetSelForm.Enabled = False
  684.             MenuFormulasGroupSel.Enabled = False
  685.             MenuDBLocation.Enabled = False
  686.             MenuLogonInfo.Enabled = False
  687.             MenuSecurity.Enabled = False
  688.             MenuSQLModify.Enabled = False
  689.             MenuSQLStoredProc.Enabled = False
  690.             MenuWindowCascade.Enabled = False
  691.             MenuWindowTileH.Enabled = False
  692.             MenuWindowTileV.Enabled = False
  693.             MenuWindowArrange.Enabled = False
  694.             OpenEngButton.Enabled = False
  695.             OpenJobButton.Enabled = True
  696.             PreviewButton.Enabled = False
  697.             PrintButton.Enabled = False
  698.             SelectionButton.Enabled = False
  699.             SortButton.Enabled = False
  700.             GroupCondButton.Enabled = False
  701.             HelpButton.Enabled = True
  702.             GraphButton.Enabled = False
  703.             FormulaButton.Enabled = False
  704.             FormatButton.Enabled = False
  705.             ExportButton.Enabled = False
  706.             SQLButton.Enabled = False
  707.   Main!StatusBar.Caption = "Job closed."
  708. End Sub
  709. Sub MenuEngineOpen_Click ()
  710. 'Open the Crystal Reports Print engine(i.e CRPE.DLL)
  711. 'Return of True(1) or false(0)
  712. On Error GoTo CRPEErr
  713. 'Check to see if Resources are high enough to open the print engine
  714. 'Never let the user drop below 20% resources. If they do they ask them
  715. 'to exit the application, close other applications down, and try running
  716. 'CRPEDemo again
  717.     FreeRes = FreeResourcesAreAbove(20)
  718.     If FreeRes = False Then
  719.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  720.       Exit Sub
  721.     End If
  722.     If PEOpenEngine() = False Then
  723.       Main!StatusBar.Caption = "The engine did not open"
  724.       Exit Sub
  725.     Else
  726.       Main!StatusBar.Caption = "The engine is now open"
  727.       'Activate open print job menu item
  728.       MenuEngineOpenJob.Enabled = True
  729.       'Activate close engine menu item
  730.       MenuEngineClose.Enabled = True
  731.       'Activate LogonServer menu item. To use PELogonServer
  732.       'you only need the engine to be open. Not the job the job as well.
  733.       MenuLogon.Enabled = True
  734.       'deactivate open engine menu item so that user doesn't open the engine twice
  735.       'opening the engine twice can cause GPFs in windows
  736.       MenuEngineOpen.Enabled = False
  737.       MenuFileNew.Enabled = False
  738.     End If
  739. 'Check to see if Print job already exists
  740.     If Jobnum <> 0 Then
  741.       Main!StatusBar.Caption = "Job is already open"
  742.     End If
  743.     Exit Sub
  744. CRPEErr:
  745.   MsgBox "Cannot find CRPE.DLL in your Path! Please exit the application and add the directory containing this DLL to your DOS path."
  746.   Exit Sub
  747. End Sub
  748. Sub MenuEngineOpenJob_Click ()
  749. 'Declarations
  750. Dim Counter As Integer, Counter1 As Integer
  751. 'Constants
  752. Counter = 0
  753. Counter1 = 0
  754. 'Check to see if Resources are high enough to open the print job
  755. 'Never let the user drop below 20% resources. If they do they ask them
  756. 'to exit the application, close other applications down, and try running
  757. 'CRPEDemo again
  758.     FreeRes = FreeResourcesAreAbove(20)
  759.     If FreeRes = False Then
  760.       MsgBox "Your System Resources are below 20% Free, the job cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  761.       Exit Sub
  762.     End If
  763. 'Invoke common dialogue to choose a report file name
  764.     On Error GoTo ErrorHandler
  765.     CmDialog1.CancelError = True
  766.     CmDialog1.Flags = OFN_HIDEREADONLY
  767.     CmDialog1.DialogTitle = "Open Report"
  768.     CmDialog1.Filter = "Crystal Reports (*.rpt)"
  769.     CmDialog1.Filename = "*.rpt"
  770.     CmDialog1.Action = 1
  771. 'Open Print job using specified file name. The return value
  772. 'is either true(1) or false(0)
  773.     If CmDialog1.Filename <> "" Then
  774.         Jobnum = PEOpenPrintJob(CmDialog1.Filename)
  775.         If Jobnum <> 0 Then
  776.             Main!StatusBar.Caption = "Job opened."
  777.             'Activate all menu items once job is opened
  778.             MenuFileNew.Enabled = False
  779.             MenuFilePrint.Enabled = True
  780.             MenuFilePrinter.Enabled = True
  781.             MenuFileWindow.Enabled = True
  782.             MenuFileFile.Enabled = True
  783.             MenuFileExport.Enabled = True
  784.             MenuEngineCloseJob.Enabled = True
  785.             MenuFormatRPTTitle.Enabled = True
  786.             MenuFormatSection.Enabled = True
  787.             MenuFormatGroupCond.Enabled = True
  788.             MenuFormatGraph.Enabled = True
  789.             MenuFieldsRecordSortField.Enabled = True
  790.             MenuFieldsGroupSortFields.Enabled = True
  791.             MenuFormulasSetFormula.Enabled = True
  792.             MenuFormulasSetSelForm.Enabled = True
  793.             MenuFormulasGroupSel.Enabled = True
  794.             MenuDBLocation.Enabled = True
  795.             MenuLogonInfo.Enabled = True
  796.             MenuSecurity.Enabled = True
  797.             MenuWindowCascade.Enabled = True
  798.             MenuWindowTileH.Enabled = True
  799.             MenuWindowTileV.Enabled = True
  800.             MenuWindowArrange.Enabled = True
  801.         Else
  802.             Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
  803.         End If
  804.     End If
  805. 'Determine what type of report(i.e. SQL or PC type) and then
  806. 'Enable or Disable the SQL Menu Items
  807. 'Declarations
  808.   Dim TableType As PETableType
  809. 'Define Structure
  810.   TableType.StructSize = Len(TableType)
  811.   TableType.DLLName = Chr$(0)
  812.   TableType.DescriptiveName = Chr$(0)
  813.   'TableType.DBType
  814. 'Determine number of tables in report
  815. NTables = PEGetNTables(Jobnum)
  816. 'Get the table type based on the specific table names
  817. For I = 0 To NTables - 1
  818.   If PEGetNthTableType(Jobnum, I, TableType) = False Then
  819.       RCode = GetErrorString(Jobnum)
  820.       MsgBox "PEGetNthTableType Error #: " + Str(ErrorCode) + " - " + RCode
  821.       Exit Sub
  822.   Else
  823.      
  824. 'Database types are returned as either 0 or 1. Return a more
  825. 'descriptive message to the message box
  826.      If TableType.DBType = 1 Then
  827.         Counter = Counter + 1
  828.      Else
  829.        Counter1 = Counter1 + 1
  830.      End If
  831.   End If
  832. Next I
  833. If Counter1 > 0 Then
  834.   MenuSQLModify.Enabled = True
  835.   MenuSQLStoredProc.Enabled = True
  836. End If
  837.        
  838.        
  839.        
  840. ErrorHandler:
  841.     Exit Sub
  842. End Sub
  843. Sub MenuFieldsGroupSortFields_Click ()
  844.  Sort.Show 1
  845. End Sub
  846. Sub MenuFieldsRecordSortField_Click ()
  847.  Sort.Show 1
  848. End Sub
  849. Sub MenuFileClose_Click ()
  850.     If Forms.Count > 1 Then
  851.         Unload ActiveForm
  852.         If Forms.Count = 2 Then
  853.             MenuFileClose.Enabled = False
  854.         End If
  855.     End If
  856. End Sub
  857. Sub MenuFileExit_Click ()
  858.     Unload Me
  859. End Sub
  860. Sub MenuFileExport_Click ()
  861. Dim ExportOptions As PEExportOptions
  862. 'Check to see if Resources are high enough to open the print engine
  863. 'Never let the user drop below 20% resources. If they do they ask them
  864. 'to exit the application, close other applications down, and try running
  865. 'CRPEDemo again
  866.     FreeRes = FreeResourcesAreAbove(20)
  867.     If FreeRes = False Then
  868.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  869.       Exit Sub
  870.     End If
  871. ExportOptions.StructSize = Len(ExportOptions)
  872. If PEGetExportOptions(Jobnum, ExportOptions) = False Then
  873.     RCode = GetErrorString(Jobnum)
  874.     MsgBox "PEGetExportOptions Error #: " + Str(ErrorCode) + " - " + RCode
  875.     Exit Sub
  876. End If
  877. If PEExportTo(Jobnum, ExportOptions) = False Then
  878.     RCode = GetErrorString(Jobnum)
  879.     MsgBox "PEExportTo Error #: " + Str(ErrorCode) + " - " + RCode
  880.     Exit Sub
  881. End If
  882. FreeRes = FreeResourcesAreAbove(20)
  883. If FreeRes = False Then
  884.   MsgBox "Your System Resources are below 20% Free, the job cannot be started! Please exit CRPEDemo, close some of your other Windows applications and try again."
  885.   Exit Sub
  886. End If
  887. If PEStartPrintJob(Jobnum, 1) = False Then
  888.     RCode = GetErrorString(Jobnum)
  889.     MsgBox "PEStartPrintJob Error #: " + Str(ErrorCode) + " - " + RCode
  890.     Exit Sub
  891.   Main!StatusBar.Caption = "Export successful."
  892. End If
  893. End Sub
  894. Sub MenuFileFile_Click ()
  895.   Dim Filename As String, Msg As String
  896.   Dim choice As Integer, FileType As Integer
  897.   Dim Options As PECharSepFileOptions
  898. 'Check to see if Resources are high enough to open the print engine
  899. 'Never let the user drop below 20% resources. If they do they ask them
  900. 'to exit the application, close other applications down, and try running
  901. 'CRPEDemo again
  902.     FreeRes = FreeResourcesAreAbove(20)
  903.     If FreeRes = False Then
  904.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  905.       Exit Sub
  906.     End If
  907.   MsgBox "Note: File format will be Character Seperated with a string delimiter of a single quote and a field delimiter of a comma. To output to any other file formats please refer to the documentation and modify the code manually. Otherwise it is recommended that the Export option be used."
  908.   CmDialog1.DefaultExt = ".txt"
  909.   CmDialog1.CancelError = True
  910.   CmDialog1.Flags = OFN_OVERWRITEPROMPT + OFN_HIDEREADONLY
  911.   CmDialog1.DialogTitle = "Save As"
  912.   CmDialog1.Filter = "Character Seperated (*.csv)"
  913.   CmDialog1.Filename = ""
  914.   On Error GoTo ErrHandler
  915.   CmDialog1.Action = 2
  916.   If CmDialog1.Filename = "" Then
  917.     Exit Sub
  918.   End If
  919.   Filename = CmDialog1.Filename
  920.   FileType = PE_FT_CHARSEPARATED
  921.   Options.StructSize = Len(Options)  ' Initialize size of structure
  922.   Options.UseReportNumberFmt = False
  923.   Options.UseReportDateFormat = True
  924.   Options.StringDelimiter = "'"
  925.   Options.FieldDelimiter = "," + Chr$(0)
  926.   ' We can't output to the file, unless it does not exist. Therefore
  927.   ' Check for the existence of the file.
  928.   If exists(Filename) Then
  929.     Kill Filename
  930.   End If
  931.   If PEOutputToFile(Jobnum, Filename, FileType, Options) = False Then
  932.     RCode = GetErrorString(Jobnum)
  933.     MsgBox "PEOutputToFile Error #: " + Str(ErrorCode) + " - " + RCode
  934.     Exit Sub
  935.   End If
  936.       
  937.   FreeRes = FreeResourcesAreAbove(20)
  938.   If FreeRes = False Then
  939.     MsgBox "Your System Resources are below 20% Free, the job cannot be started! Please exit CRPEDemo, close some of your other Windows applications and try again."
  940.     Exit Sub
  941.   End If
  942.   If PEStartPrintJob(Jobnum, True) = False Then
  943.     RCode = GetErrorString(Jobnum)
  944.     MsgBox "PEStartPrintJob Error #: " + Str(ErrorCode) + " - " + RCode
  945.     Exit Sub
  946.   End If
  947.       
  948.   Main!StatusBar.Caption = "Printing to File was successful."
  949. ErrHandler:
  950.   Exit Sub
  951. End Sub
  952. Sub MenuFileNew_Click ()
  953. Dim C As New Child
  954. Dim Jobnum As Integer
  955. 'Open the Crystal Reports Print engine(i.e CRPE.DLL)
  956. 'Return of True(1) or false(0)
  957.     If PEOpenEngine() = False Then
  958.       Main!StatusBar.Caption = "The engine did not open"
  959.     Else
  960.       Main!StatusBar.Caption = "The engine is now open"
  961.     End If
  962. 'Check to see if Print job already exists
  963.     If Jobnum <> 0 Then
  964.       Main!StatusBar.Caption = "Job is already open"
  965.     End If
  966. 'Invoke common dialogue to choose a report file name
  967.     On Error GoTo ErrrHandler
  968.     CmDialog1.CancelError = True
  969.     CmDialog1.Flags = OFN_HIDEREADONLY
  970.     CmDialog1.DialogTitle = "Open Report"
  971.     CmDialog1.Filter = "Crystal Reports (*.rpt)"
  972.     CmDialog1.Filename = "*.rpt"
  973.     CmDialog1.Action = 1
  974. 'Open Print job using specified file name. The return value
  975. 'is either true(1) or false(0)
  976.     If CmDialog1.Filename <> "" Then
  977.         Jobnum = PEOpenPrintJob(CmDialog1.Filename)
  978.         If Jobnum <> 0 Then
  979.             Main!StatusBar.Caption = "Job opened."
  980.         Else
  981.             Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
  982.         End If
  983.     End If
  984. 'Set the report window handle equal to that of the MDI child
  985. 'form so that our print window prints inside of the Window frame
  986. 'created by the Windows API call
  987.     Report_ParentWindowHandle = C.hWnd
  988.     Screen.MousePointer = 11
  989.     C.Caption = "MDIChild-CRPEDemo"
  990. 'Set the border style of the print window so that it has no border,max or min
  991. 'buttons, control box etc.
  992.     'Border_style% = 268435456
  993. 'Send the Print job to be printed to a window
  994.     If PEOutPutToWindow(Jobnum, C.Caption, ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight, 268435456, C.hWnd) = False Then
  995.       Main!StatusBar.Caption = "Output to Window has failed."
  996.     Else
  997.       Main!StatusBar.Caption = "Output to Window was successful."
  998.     End If
  999. 'Starts the desired print job
  1000.     If PEStartPrintJob(Jobnum, True) = False Then
  1001.       Main!StatusBar.Caption = "Printing To Window has failed."
  1002.     Else
  1003.       Main!StatusBar.Caption = "Printing to Window was successful."
  1004.     End If
  1005.     Main!StatusBar.Caption = " Active Window :- " & C.Caption
  1006.     MenuFileClose.Enabled = True
  1007.     Screen.MousePointer = 0
  1008.     Exit Sub
  1009. ErrrHandler:
  1010.     PECloseEngine
  1011.     Exit Sub
  1012. End Sub
  1013. Sub MenuFilePrinter_Click ()
  1014. 'Check to see if Resources are high enough to open the print engine
  1015. 'Never let the user drop below 20% resources. If they do they ask them
  1016. 'to exit the application, close other applications down, and try running
  1017. 'CRPEDemo again
  1018.     FreeRes = FreeResourcesAreAbove(20)
  1019.     If FreeRes = False Then
  1020.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1021.       Exit Sub
  1022.     End If
  1023. PrintFrm.Show 1
  1024. End Sub
  1025. Sub MenuFileWindow_Click ()
  1026. 'Check to see if Resources are high enough to open the print engine
  1027. 'Never let the user drop below 20% resources. If they do they ask them
  1028. 'to exit the application, close other applications down, and try running
  1029. 'CRPEDemo again
  1030.     FreeRes = FreeResourcesAreAbove(20)
  1031.     If FreeRes = False Then
  1032.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1033.       Exit Sub
  1034.     End If
  1035. WinFrm.Show 1
  1036. End Sub
  1037. Sub MenuFormatGraph_Click ()
  1038.   Graph.Show 1
  1039. End Sub
  1040. Sub MenuFormatGroupCond_Click ()
  1041.  GroupCond.Show 1
  1042. End Sub
  1043. Sub MenuFormatMinSectionHeight_Click ()
  1044.  MsgBox "Not Yet Implemented!"
  1045. End Sub
  1046. Sub MenuFormatRptTitle_Click ()
  1047.   RPTTITLE.Show 1
  1048. End Sub
  1049. Sub MenuFormatSection_Click ()
  1050.   Section.Show 1
  1051. End Sub
  1052. Sub MenuFormatSetLineHeight_Click ()
  1053.  MsgBox "Not Yet Implemented!"
  1054. End Sub
  1055. Sub MenuFormatSetMargins_Click ()
  1056.  MsgBox "Not Yet Implemented!"
  1057. End Sub
  1058. Sub MenuFormatSetSecFormat_Click ()
  1059.  Section.Show
  1060. End Sub
  1061. Sub MenuFormatSetSectionFont_Click ()
  1062. 'Invoke common dialogue to choose a report file name
  1063.     'CMDialog1.Action = 4
  1064.      Font.Show
  1065. End Sub
  1066. Sub MenuFormulaGroupSel_Click ()
  1067.  SetFormula.Show
  1068. End Sub
  1069. Sub MenuFormulasGroupSel_Click ()
  1070.    SetFormula.Show 1
  1071. End Sub
  1072. Sub MenuFormulasSetFormula_Click ()
  1073.  SetFormula.Show 1
  1074. End Sub
  1075. Sub MenuFormulasSetSelForm_Click ()
  1076.   SetFormula.Show 1
  1077. End Sub
  1078. Sub MenuGroupCond_Click ()
  1079.  GroupCond.Show
  1080. End Sub
  1081. Sub MenuHelpAbout_Click ()
  1082.  About.Show 1
  1083. End Sub
  1084. Sub MenuHelpCRWHLP_Click ()
  1085.  RCode = Shell("Winhelp c:\crw\crw.hlp", 3)
  1086. End Sub
  1087. Sub MenuHelpWhere_Click ()
  1088. 'Declarations
  1089.     Dim Response As Integer
  1090.     Dim RCode As Integer
  1091. 'Allow user to open CRPEDEMO.TXT file if they choose.
  1092. 'If the user chooses yes from the message box they will automatically
  1093. 'be shelled to notepad with the appropriate text file opened
  1094.     Response = MsgBox("A list of all Print Engine calls included in CRPEDemo can be found in the CRPEDEMO.TXT. Would you like to view the text file now?", 4, "Graph Type Tip")
  1095.     If Response = 6 Then
  1096.        'shell to notepad
  1097.        CRPEDemoPath$ = "NOTEPAD.EXE " & app.Path & "\crpedemo.txt"
  1098.        RCode = Shell(CRPEDemoPath$, 3)
  1099.     Else
  1100.       Exit Sub
  1101.     End If
  1102. End Sub
  1103. Sub MenuLogoff_Click ()
  1104.     Dim logonInfo As PELogonInfo
  1105.     logonInfo.StructSize = Len(logonInfo)
  1106.     logonInfo.ServerName = "ODBCSQL" + Chr$(0)
  1107.     logonInfo.DatabaseName = "pubs" + Chr$(0)
  1108.     logonInfo.UserID = "tech" + Chr$(0)
  1109.     logonInfo.Password = "tech" + Chr$(0)
  1110.     If PELogOFFServer("PDSODBC.DLL", logonInfo) = 1 Then
  1111.        MsgBox ("PELogOFFServer Succeeded!")
  1112.     Else
  1113.       RCode = GetErrorString(Jobnum)
  1114.       MsgBox "PELogOFFServer Error #: " + Str(ErrorCode) + " - " + RCode
  1115.     End If
  1116. End Sub
  1117. Sub MenuLogon_Click ()
  1118. 'Check to see if Resources are high enough to logon to the server
  1119. 'Never let the user drop below 20% resources. If they do they ask them
  1120. 'to exit the application, close other applications down, and try running
  1121. 'CRPEDemo again
  1122.     FreeRes = FreeResourcesAreAbove(20)
  1123.     If FreeRes = False Then
  1124.       MsgBox "Your System Resources are below 20% Free, you cannot logon to the server! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1125.       Exit Sub
  1126.     End If
  1127.     Dim logonInfo As PELogonInfo
  1128.     logonInfo.StructSize = Len(logonInfo)
  1129.     logonInfo.ServerName = "ODBCSQL" + Chr$(0)
  1130.     logonInfo.DatabaseName = "pubs" + Chr$(0)
  1131.     logonInfo.UserID = "tech" + Chr$(0)
  1132.     logonInfo.Password = "tech" + Chr$(0)
  1133.     If PELogOnServer("PDSODBC.DLL", logonInfo) = 1 Then
  1134.       MsgBox ("PELogOnServer Succeeded!")
  1135.       MenuLogoff.Enabled = True
  1136.     Else
  1137.       RCode = GetErrorString(Jobnum)
  1138.       MsgBox "PELogOnServer Error #: " + Str(ErrorCode) + " - " + RCode
  1139.       Exit Sub
  1140.     End If
  1141. End Sub
  1142. Sub MenuLogonInfo_Click ()
  1143.  SETLOGON.Show 1
  1144. End Sub
  1145. Sub MenuModSQL_Click ()
  1146.  SQLQuery.Show
  1147. End Sub
  1148. Sub MenuPrintFile_Click ()
  1149. Dim Path As String
  1150. Path = InputBox("Please enter text file name with path:", "Text File Name")
  1151. If PEOutputToFile(Jobnum, Path, 2, 0) = 1 Then
  1152.     MsgBox ("Export to file was successful!")
  1153.  Else
  1154.     MsgBox ("Export to file has failed!")
  1155.  End If
  1156. End Sub
  1157. Sub MenuPrintWindow_Click ()
  1158. Dim C As New Child
  1159.     Report_ParentWindowHandle = C.hWnd
  1160.     'Screen.MousePointer = 11
  1161.     C.Caption = "MDIChild - " & Forms.Count
  1162. 'Set the border style of the print window so that it has no border,max or min
  1163. 'buttons, control box etc.
  1164.     'Border_style% = 268435456
  1165. 'Send the Print job to be printed to a window
  1166.     If PEOutPutToWindow(Jobnum, C.Caption, ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight, 268435456, C.hWnd) = False Then
  1167.       Main!StatusBar.Caption = "Output to Window has failed."
  1168.     Else
  1169.       Main!StatusBar.Caption = "Output to Window was successful."
  1170.     End If
  1171. End Sub
  1172. Sub MenuSecurity_Click ()
  1173.  Security.Show 1
  1174. End Sub
  1175. Sub MenuServerManagementLogoffServer_Click ()
  1176.     Dim logonInfo As PELogonInfo
  1177.     logonInfo.StructSize = Len(logonInfo)
  1178.     logonInfo.ServerName = "ODBCSQL" + Chr$(0)
  1179.     logonInfo.DatabaseName = "pubs" + Chr$(0)
  1180.     logonInfo.UserID = "tech" + Chr$(0)
  1181.     logonInfo.Password = "tech" + Chr$(0)
  1182.     If PELogOFFServer("PDSODBC.DLL", logonInfo) = 1 Then
  1183.        MsgBox ("PELogOFFServer Succeeded!")
  1184.     Else
  1185.       RCode = GetErrorString(Jobnum)
  1186.       MsgBox "PELogOFFServer Error #: " + Str(ErrorCode) + " - " + RCode
  1187.     End If
  1188. End Sub
  1189. Sub MenuServerManagementLogonInfo_Click ()
  1190.   SETLOGON.Show
  1191. End Sub
  1192. Sub MenuServerManagementLogonServer_Click ()
  1193.     Dim logonInfo As PELogonInfo
  1194.     logonInfo.StructSize = Len(logonInfo)
  1195.     logonInfo.ServerName = "ODBCSQL" + Chr$(0)
  1196.     logonInfo.DatabaseName = "pubs" + Chr$(0)
  1197.     logonInfo.UserID = "tech" + Chr$(0)
  1198.     logonInfo.Password = "tech" + Chr$(0)
  1199.     If PELogOnServer("PDSODBC.DLL", logonInfo) = 1 Then
  1200.       MsgBox ("PELogOnServer Succeeded!")
  1201.     Else
  1202.       RCode = GetErrorString(Jobnum)
  1203.       MsgBox "PELogOnServer Error #: " + Str(ErrorCode) + " - " + RCode
  1204.     End If
  1205. End Sub
  1206. Sub MenuServerManagementSQLQuery_Click ()
  1207.  SQLQuery.Show
  1208. End Sub
  1209. Sub MenuSQLModify_Click ()
  1210.    SQLQuery.Show 1
  1211. End Sub
  1212. Sub MenuSQLStoredProc_Click ()
  1213.   storedproc.Show 1
  1214. End Sub
  1215. Sub MenuWindowArrange_Click ()
  1216.     Me.Arrange ARRANGE_ICONS
  1217. End Sub
  1218. Sub MenuWindowCascade_Click ()
  1219.     Me.Arrange CASCADE
  1220. End Sub
  1221. Sub MenuWindowTileH_Click ()
  1222.     Me.Arrange TILE_HORIZONTAL
  1223. End Sub
  1224. Sub MenuWindowTileV_Click ()
  1225.     Me.Arrange TILE_VERTICAL
  1226. End Sub
  1227. Sub OpenEngButton_Click ()
  1228. 'Open the Crystal Reports Print engine(i.e CRPE.DLL)
  1229. 'Return of True(1) or false(0)
  1230. On Error GoTo CRPEErrb
  1231. 'Check to see if Resources are high enough to open the print engine
  1232. 'Never let the user drop below 20% resources. If they do they ask them
  1233. 'to exit the application, close other applications down, and try running
  1234. 'CRPEDemo again
  1235.     FreeRes = FreeResourcesAreAbove(20)
  1236.     If FreeRes = False Then
  1237.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1238.       Exit Sub
  1239.     End If
  1240.     If PEOpenEngine() = False Then
  1241.       Main!StatusBar.Caption = "The engine did not open"
  1242.       Exit Sub
  1243.     Else
  1244.       Main!StatusBar.Caption = "The engine is now open"
  1245.       'Activate open print job menu item
  1246.       MenuEngineOpenJob.Enabled = True
  1247.       'Activate close engine menu item
  1248.       MenuEngineClose.Enabled = True
  1249.       'Activate LogonServer menu item. To use PELogonServer
  1250.       'you only need the engine to be open. Not the job the job as well.
  1251.       MenuLogon.Enabled = True
  1252.       'deactivate open engine menu item so that user doesn't open the engine twice
  1253.       'opening the engine twice can cause GPFs in windows
  1254.       MenuEngineOpen.Enabled = False
  1255.       MenuFileNew.Enabled = False
  1256.       OpenEngButton.Enabled = False
  1257.       OpenJobButton.Enabled = True
  1258.     End If
  1259. 'Check to see if Print job already exists
  1260.     If Jobnum <> 0 Then
  1261.       Main!StatusBar.Caption = "Job is already open"
  1262.     End If
  1263.     Exit Sub
  1264. CRPEErrb:
  1265.   MsgBox "Cannot find CRPE.DLL in your Path! Please exit the application and add the directory containing this DLL to your DOS path."
  1266.   Exit Sub
  1267. End Sub
  1268. Sub OpenJobbutton_Click ()
  1269. 'Declarations
  1270. Dim Counter As Integer, Counter1 As Integer
  1271. 'Constants
  1272. Counter = 0
  1273. Counter1 = 0
  1274. 'Check to see if Resources are high enough to open the print job
  1275. 'Never let the user drop below 20% resources. If they do they ask them
  1276. 'to exit the application, close other applications down, and try running
  1277. 'CRPEDemo again
  1278.     FreeRes = FreeResourcesAreAbove(20)
  1279.     If FreeRes = False Then
  1280.       MsgBox "Your System Resources are below 20% Free, the job cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1281.       Exit Sub
  1282.     End If
  1283. 'Invoke common dialogue to choose a report file name
  1284.     On Error GoTo ErrorHandlerb
  1285.     CmDialog1.CancelError = True
  1286.     CmDialog1.Flags = OFN_HIDEREADONLY
  1287.     CmDialog1.DialogTitle = "Open Report"
  1288.     CmDialog1.Filter = "Crystal Reports (*.rpt)"
  1289.     CmDialog1.Filename = "*.rpt"
  1290.     CmDialog1.Action = 1
  1291. 'Open Print job using specified file name. The return value
  1292. 'is either true(1) or false(0)
  1293.     If CmDialog1.Filename <> "" Then
  1294.         Jobnum = PEOpenPrintJob(CmDialog1.Filename)
  1295.         If Jobnum <> 0 Then
  1296.             Main!StatusBar.Caption = "Job opened."
  1297.             'Activate all menu items once job is opened
  1298.             MenuFileNew.Enabled = False
  1299.             MenuFilePrint.Enabled = True
  1300.             MenuFilePrinter.Enabled = True
  1301.             MenuFileWindow.Enabled = True
  1302.             MenuFileFile.Enabled = True
  1303.             MenuFileExport.Enabled = True
  1304.             MenuEngineCloseJob.Enabled = True
  1305.             MenuFormatRPTTitle.Enabled = True
  1306.             MenuFormatSection.Enabled = True
  1307.             MenuFormatGroupCond.Enabled = True
  1308.             MenuFormatGraph.Enabled = True
  1309.             MenuFieldsRecordSortField.Enabled = True
  1310.             MenuFieldsGroupSortFields.Enabled = True
  1311.             MenuFormulasSetFormula.Enabled = True
  1312.             MenuFormulasSetSelForm.Enabled = True
  1313.             MenuFormulasGroupSel.Enabled = True
  1314.             MenuDBLocation.Enabled = True
  1315.             MenuLogonInfo.Enabled = True
  1316.             MenuSecurity.Enabled = True
  1317.             MenuWindowCascade.Enabled = True
  1318.             MenuWindowTileH.Enabled = True
  1319.             MenuWindowTileV.Enabled = True
  1320.             MenuWindowArrange.Enabled = True
  1321.             PreviewButton.Enabled = True
  1322.             PrintButton.Enabled = True
  1323.             SelectionButton.Enabled = True
  1324.             SortButton.Enabled = True
  1325.             GroupCondButton.Enabled = True
  1326.             HelpButton.Enabled = True
  1327.             GraphButton.Enabled = True
  1328.             FormulaButton.Enabled = True
  1329.             FormatButton.Enabled = True
  1330.             ExportButton.Enabled = True
  1331.         Else
  1332.             Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
  1333.         End If
  1334.     End If
  1335. 'Determine what type of report(i.e. SQL or PC type) and then
  1336. 'Enable or Disable the SQL Menu Items
  1337. 'Declarations
  1338.   Dim TableType As PETableType
  1339. 'Define Structure
  1340.   TableType.StructSize = Len(TableType)
  1341.   TableType.DLLName = Chr$(0)
  1342.   TableType.DescriptiveName = Chr$(0)
  1343.   'TableType.DBType
  1344. 'Determine number of tables in report
  1345. NTables = PEGetNTables(Jobnum)
  1346. 'Get the table type based on the specific table names
  1347. For I = 0 To NTables - 1
  1348.   If PEGetNthTableType(Jobnum, I, TableType) = False Then
  1349.       RCode = GetErrorString(Jobnum)
  1350.       MsgBox "PEGetNthTableType Error #: " + Str(ErrorCode) + " - " + RCode
  1351.       Exit Sub
  1352.   Else
  1353.      
  1354. 'Database types are returned as either 0 or 1. Return a more
  1355. 'descriptive message to the message box
  1356.      If TableType.DBType = 1 Then
  1357.         Counter = Counter + 1
  1358.      Else
  1359.        Counter1 = Counter1 + 1
  1360.      End If
  1361.   End If
  1362. Next I
  1363. If Counter1 > 0 Then
  1364.   MenuSQLModify.Enabled = True
  1365.   MenuSQLStoredProc.Enabled = True
  1366.   SQLButton.Enabled = True
  1367. End If
  1368.        
  1369.        
  1370.        
  1371. ErrorHandlerb:
  1372.     Exit Sub
  1373. End Sub
  1374. Sub Preview_Click ()
  1375. Dim C As New Child
  1376. Dim Jobnum As Integer
  1377. 'Open the Crystal Reports Print engine(i.e CRPE.DLL)
  1378. 'Return of True(1) or false(0)
  1379.     If PEOpenEngine() = False Then
  1380.       Main!StatusBar.Caption = "The engine did not open"
  1381.     Else
  1382.       Main!StatusBar.Caption = "The engine is now open"
  1383.     End If
  1384. 'Check to see if Print job already exists
  1385.     If Jobnum <> 0 Then
  1386.       Main!StatusBar.Caption = "Job is already open"
  1387.     End If
  1388. 'Invoke common dialogue to choose a report file name
  1389.     CmDialog1.Action = 1
  1390. 'Open Print job using specified file name. The return value
  1391. 'is either true(1) or false(0)
  1392.     If CmDialog1.Filename <> "" Then
  1393.         Jobnum = PEOpenPrintJob(CmDialog1.Filename)
  1394.         If Jobnum <> 0 Then
  1395.             Main!StatusBar.Caption = "Job opened."
  1396.         Else
  1397.             Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
  1398.         End If
  1399.     End If
  1400. 'Set the report window handle equal to that of the MDI child
  1401. 'form so that our print window prints inside of the Window frame
  1402. 'created by the Windows API call
  1403.     Report_ParentWindowHandle = C.hWnd
  1404.     Screen.MousePointer = 11
  1405.     C.Caption = "MDIChild - " & Forms.Count
  1406. 'Set the border style of the print window so that it has no border,max or min
  1407. 'buttons, control box etc.
  1408.     'Border_style% = 268435456
  1409. 'Send the Print job to be printed to a window
  1410.     If PEOutPutToWindow(Jobnum, C.Caption, ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight, 268435456, C.hWnd) = False Then
  1411.       Main!StatusBar.Caption = "Output to Window has failed."
  1412.     Else
  1413.       Main!StatusBar.Caption = "Output to Window was successful."
  1414.     End If
  1415. 'Starts the desired print job
  1416.     If PEStartPrintJob(Jobnum, True) = False Then
  1417.       Main!StatusBar.Caption = "Printing To Window has failed."
  1418.     Else
  1419.       Main!StatusBar.Caption = "Printing to Window was successful."
  1420.     End If
  1421.     Main!StatusBar.Caption = " Active Window :- " & C.Caption
  1422.     MenuFileClose.Enabled = True
  1423.     Screen.MousePointer = 0
  1424. End Sub
  1425. Sub Previewbutton_Click ()
  1426. 'Check to see if Resources are high enough to open the print engine
  1427. 'Never let the user drop below 20% resources. If they do they ask them
  1428. 'to exit the application, close other applications down, and try running
  1429. 'CRPEDemo again
  1430.     FreeRes = FreeResourcesAreAbove(20)
  1431.     If FreeRes = False Then
  1432.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1433.       Exit Sub
  1434.     End If
  1435. WinFrm.Show 1
  1436. End Sub
  1437. Sub PrintButton_Click ()
  1438. 'Check to see if Resources are high enough to open the print engine
  1439. 'Never let the user drop below 20% resources. If they do they ask them
  1440. 'to exit the application, close other applications down, and try running
  1441. 'CRPEDemo again
  1442.     FreeRes = FreeResourcesAreAbove(20)
  1443.     If FreeRes = False Then
  1444.       MsgBox "Your System Resources are below 20% Free, the engine cannot be opened! Please exit CRPEDemo, close some of your other Windows applications and try again."
  1445.       Exit Sub
  1446.     End If
  1447. PrintFrm.Show 1
  1448. End Sub
  1449. Sub SelectionButton_Click ()
  1450. SetFormula.Show 1
  1451. End Sub
  1452. Sub SortButton_Click ()
  1453.   Sort.Show 1
  1454. End Sub
  1455. Sub SQLButton_Click ()
  1456.  SQLQuery.Show 1
  1457. End Sub
  1458. Sub Timer1_Timer ()
  1459.        Dim curhWnd As Integer      'Current hWnd
  1460.        Dim p As POINTAPI
  1461.        Static LasthWnd As Integer  'Hold previous hWnd
  1462.        ' Make sure the program has the input focus:
  1463.        If GetActiveWindow() = Main.hWnd Then
  1464.           ' Initialize point structure:
  1465.           Call GetCursorPos(p)
  1466.           ' Which window is the mouse cursor over?
  1467.           curhWnd = WindowFromPoint(p.y, p.x)
  1468.           ' Same as last window? If so, don't need to redraw:
  1469.           If curhWnd <> LasthWnd Then
  1470.              ' Store the current hWnd:
  1471.              LasthWnd = curhWnd
  1472.              ' Decrease timer interval to 5 ms (could choose 1 ms):
  1473.              Timer1.Interval = 5
  1474.              ' Which control is the cursor over?
  1475.              Select Case curhWnd
  1476.                 Case OpenEngButton.hWnd
  1477.                    DisplayHelp "Open Engine"
  1478.                 Case OpenJobButton.hWnd
  1479.                    DisplayHelp "Open Print Job"
  1480.                 Case PreviewButton.hWnd
  1481.                    DisplayHelp "Print Preview"
  1482.                 Case PrintButton.hWnd
  1483.                    DisplayHelp "Print"
  1484.                 Case ExportButton.hWnd
  1485.                    DisplayHelp "Export"
  1486.                 Case FormatButton.hWnd
  1487.                    DisplayHelp "Format Section"
  1488.                 Case GraphButton.hWnd
  1489.                    DisplayHelp "Format Graph"
  1490.                 Case GroupCondButton.hWnd
  1491.                    DisplayHelp "Group Condition"
  1492.                 Case SortButton.hWnd
  1493.                    DisplayHelp "Sort"
  1494.                 Case FormulaButton.hWnd
  1495.                    DisplayHelp "Formula"
  1496.                 Case SelectionButton.hWnd
  1497.                    DisplayHelp "Selection Formula"
  1498.                 Case HelpButton.hWnd
  1499.                    DisplayHelp "Crystal Reports Help"
  1500.                 Case SQLButton.hWnd
  1501.                    DisplayHelp "Modify SQL"
  1502.                 'Case GetWindow(Combo1.hWnd, GW_CHILD) 'Edit box of combo box
  1503.                  '  DisplayHelp "Edit Box of Combo Box"
  1504.                ' Case hScroll1.hWnd
  1505.                  '  DisplayHelp "hScroll Bar"
  1506.               '  Case vScroll1.hWnd
  1507.                   ' DisplayHelp "vScroll Bar"
  1508.                 Case frmHelp.hWnd
  1509.                    ' If it moves onto the help window, hide it:
  1510.                    frmHelp.Hide
  1511.                 Case Else
  1512.                    ' Cursor is over the form or something else, so
  1513.                    ' change interval back to 1 sec delay:
  1514.                    DisplayHelp ""
  1515.                    Timer1.Interval = 1000
  1516.              End Select
  1517.           End If
  1518.        End If
  1519. End Sub
  1520. Sub ZoomButton_Click ()
  1521. 'Check if job is open
  1522. End Sub
  1523.