' This function returns True if a given file exists, False otherwise
Dim n As Integer
On Error GoTo handler
n = FreeFile
' Try to open file for input. If successful, file exists
Open f For Input As #n
Close #n
exists = True
Exit Function
handler:
' If we get here the file does not exist
exists = False
Exit Function
End Function
Sub ExportButton_Click ()
Dim ExportOptions As PEExportOptions
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
ExportOptions.StructSize = Len(ExportOptions)
If PEGetExportOptions(Jobnum, ExportOptions) = False Then
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."
MsgBox "CRPE.DLL was not loaded. Please try running application again once the DLL is in your path."
Exit Sub
End Sub
Sub MenuDBLocation_Click ()
Tablem.Show 1
End Sub
Sub MenuEditCopy_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuEditCut_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuEditPaste_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuEditUndo_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuEngineClose_Click ()
PECloseEngine
'Deactivate all menu items that were activated when opening
'the engine and the opening the print job
'Activate all menu items once job is opened
MenuEngineOpenJob.Enabled = False
MenuEngineClose.Enabled = False
MenuLogon.Enabled = False
MenuEngineOpen.Enabled = True
MenuFileNew.Enabled = True
MenuFilePrint.Enabled = False
MenuFilePrinter.Enabled = False
MenuFileWindow.Enabled = False
MenuFileFile.Enabled = False
MenuFileExport.Enabled = False
MenuEngineCloseJob.Enabled = False
MenuFormatRPTTitle.Enabled = False
MenuFormatSection.Enabled = False
MenuFormatGroupCond.Enabled = False
MenuFormatGraph.Enabled = False
MenuFieldsRecordSortField.Enabled = False
MenuFieldsGroupSortFields.Enabled = False
MenuFormulasSetFormula.Enabled = False
MenuFormulasSetSelForm.Enabled = False
MenuFormulasGroupSel.Enabled = False
MenuDBLocation.Enabled = False
MenuLogonInfo.Enabled = False
MenuSecurity.Enabled = False
MenuSQLModify.Enabled = False
MenuSQLStoredProc.Enabled = False
MenuWindowCascade.Enabled = False
MenuWindowTileH.Enabled = False
MenuWindowTileV.Enabled = False
MenuWindowArrange.Enabled = False
OpenEngButton.Enabled = True
OpenJobButton.Enabled = False
PreviewButton.Enabled = False
PrintButton.Enabled = False
SelectionButton.Enabled = False
SortButton.Enabled = False
GroupCondButton.Enabled = False
HelpButton.Enabled = True
GraphButton.Enabled = False
FormulaButton.Enabled = False
FormatButton.Enabled = False
ExportButton.Enabled = False
SQLButton.Enabled = False
Main!StatusBar.Caption = "The engine is now closed."
End Sub
Sub MenuEngineCloseJob_Click ()
PEClosePrintJob (Jobnum)
Jobnum = 0
'Deactivate all menu items that were active after
'opening the print job
MenuFileNew.Enabled = False
MenuFilePrint.Enabled = False
MenuFilePrinter.Enabled = False
MenuFileWindow.Enabled = False
MenuFileFile.Enabled = False
MenuFileExport.Enabled = False
MenuEngineCloseJob.Enabled = False
MenuFormatRPTTitle.Enabled = False
MenuFormatSection.Enabled = False
MenuFormatGroupCond.Enabled = False
MenuFormatGraph.Enabled = False
MenuFieldsRecordSortField.Enabled = False
MenuFieldsGroupSortFields.Enabled = False
MenuFormulasSetFormula.Enabled = False
MenuFormulasSetSelForm.Enabled = False
MenuFormulasGroupSel.Enabled = False
MenuDBLocation.Enabled = False
MenuLogonInfo.Enabled = False
MenuSecurity.Enabled = False
MenuSQLModify.Enabled = False
MenuSQLStoredProc.Enabled = False
MenuWindowCascade.Enabled = False
MenuWindowTileH.Enabled = False
MenuWindowTileV.Enabled = False
MenuWindowArrange.Enabled = False
OpenEngButton.Enabled = False
OpenJobButton.Enabled = True
PreviewButton.Enabled = False
PrintButton.Enabled = False
SelectionButton.Enabled = False
SortButton.Enabled = False
GroupCondButton.Enabled = False
HelpButton.Enabled = True
GraphButton.Enabled = False
FormulaButton.Enabled = False
FormatButton.Enabled = False
ExportButton.Enabled = False
SQLButton.Enabled = False
Main!StatusBar.Caption = "Job closed."
End Sub
Sub MenuEngineOpen_Click ()
'Open the Crystal Reports Print engine(i.e CRPE.DLL)
'Return of True(1) or false(0)
On Error GoTo CRPEErr
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
If PEOpenEngine() = False Then
Main!StatusBar.Caption = "The engine did not open"
Exit Sub
Else
Main!StatusBar.Caption = "The engine is now open"
'Activate open print job menu item
MenuEngineOpenJob.Enabled = True
'Activate close engine menu item
MenuEngineClose.Enabled = True
'Activate LogonServer menu item. To use PELogonServer
'you only need the engine to be open. Not the job the job as well.
MenuLogon.Enabled = True
'deactivate open engine menu item so that user doesn't open the engine twice
'opening the engine twice can cause GPFs in windows
MenuEngineOpen.Enabled = False
MenuFileNew.Enabled = False
End If
'Check to see if Print job already exists
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job is already open"
End If
Exit Sub
CRPEErr:
MsgBox "Cannot find CRPE.DLL in your Path! Please exit the application and add the directory containing this DLL to your DOS path."
Exit Sub
End Sub
Sub MenuEngineOpenJob_Click ()
'Declarations
Dim Counter As Integer, Counter1 As Integer
'Constants
Counter = 0
Counter1 = 0
'Check to see if Resources are high enough to open the print job
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
'Invoke common dialogue to choose a report file name
On Error GoTo ErrorHandler
CmDialog1.CancelError = True
CmDialog1.Flags = OFN_HIDEREADONLY
CmDialog1.DialogTitle = "Open Report"
CmDialog1.Filter = "Crystal Reports (*.rpt)"
CmDialog1.Filename = "*.rpt"
CmDialog1.Action = 1
'Open Print job using specified file name. The return value
'is either true(1) or false(0)
If CmDialog1.Filename <> "" Then
Jobnum = PEOpenPrintJob(CmDialog1.Filename)
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job opened."
'Activate all menu items once job is opened
MenuFileNew.Enabled = False
MenuFilePrint.Enabled = True
MenuFilePrinter.Enabled = True
MenuFileWindow.Enabled = True
MenuFileFile.Enabled = True
MenuFileExport.Enabled = True
MenuEngineCloseJob.Enabled = True
MenuFormatRPTTitle.Enabled = True
MenuFormatSection.Enabled = True
MenuFormatGroupCond.Enabled = True
MenuFormatGraph.Enabled = True
MenuFieldsRecordSortField.Enabled = True
MenuFieldsGroupSortFields.Enabled = True
MenuFormulasSetFormula.Enabled = True
MenuFormulasSetSelForm.Enabled = True
MenuFormulasGroupSel.Enabled = True
MenuDBLocation.Enabled = True
MenuLogonInfo.Enabled = True
MenuSecurity.Enabled = True
MenuWindowCascade.Enabled = True
MenuWindowTileH.Enabled = True
MenuWindowTileV.Enabled = True
MenuWindowArrange.Enabled = True
Else
Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
End If
End If
'Determine what type of report(i.e. SQL or PC type) and then
'Enable or Disable the SQL Menu Items
'Declarations
Dim TableType As PETableType
'Define Structure
TableType.StructSize = Len(TableType)
TableType.DLLName = Chr$(0)
TableType.DescriptiveName = Chr$(0)
'TableType.DBType
'Determine number of tables in report
NTables = PEGetNTables(Jobnum)
'Get the table type based on the specific table names
For I = 0 To NTables - 1
If PEGetNthTableType(Jobnum, I, TableType) = False Then
'Database types are returned as either 0 or 1. Return a more
'descriptive message to the message box
If TableType.DBType = 1 Then
Counter = Counter + 1
Else
Counter1 = Counter1 + 1
End If
End If
Next I
If Counter1 > 0 Then
MenuSQLModify.Enabled = True
MenuSQLStoredProc.Enabled = True
End If
ErrorHandler:
Exit Sub
End Sub
Sub MenuFieldsGroupSortFields_Click ()
Sort.Show 1
End Sub
Sub MenuFieldsRecordSortField_Click ()
Sort.Show 1
End Sub
Sub MenuFileClose_Click ()
If Forms.Count > 1 Then
Unload ActiveForm
If Forms.Count = 2 Then
MenuFileClose.Enabled = False
End If
End If
End Sub
Sub MenuFileExit_Click ()
Unload Me
End Sub
Sub MenuFileExport_Click ()
Dim ExportOptions As PEExportOptions
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
ExportOptions.StructSize = Len(ExportOptions)
If PEGetExportOptions(Jobnum, ExportOptions) = False Then
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."
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
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."
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."
Main!StatusBar.Caption = "Printing to File was successful."
ErrHandler:
Exit Sub
End Sub
Sub MenuFileNew_Click ()
Dim C As New Child
Dim Jobnum As Integer
'Open the Crystal Reports Print engine(i.e CRPE.DLL)
'Return of True(1) or false(0)
If PEOpenEngine() = False Then
Main!StatusBar.Caption = "The engine did not open"
Else
Main!StatusBar.Caption = "The engine is now open"
End If
'Check to see if Print job already exists
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job is already open"
End If
'Invoke common dialogue to choose a report file name
On Error GoTo ErrrHandler
CmDialog1.CancelError = True
CmDialog1.Flags = OFN_HIDEREADONLY
CmDialog1.DialogTitle = "Open Report"
CmDialog1.Filter = "Crystal Reports (*.rpt)"
CmDialog1.Filename = "*.rpt"
CmDialog1.Action = 1
'Open Print job using specified file name. The return value
'is either true(1) or false(0)
If CmDialog1.Filename <> "" Then
Jobnum = PEOpenPrintJob(CmDialog1.Filename)
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job opened."
Else
Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
End If
End If
'Set the report window handle equal to that of the MDI child
'form so that our print window prints inside of the Window frame
'created by the Windows API call
Report_ParentWindowHandle = C.hWnd
Screen.MousePointer = 11
C.Caption = "MDIChild-CRPEDemo"
'Set the border style of the print window so that it has no border,max or min
'buttons, control box etc.
'Border_style% = 268435456
'Send the Print job to be printed to a window
If PEOutPutToWindow(Jobnum, C.Caption, ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight, 268435456, C.hWnd) = False Then
Main!StatusBar.Caption = "Output to Window has failed."
Else
Main!StatusBar.Caption = "Output to Window was successful."
End If
'Starts the desired print job
If PEStartPrintJob(Jobnum, True) = False Then
Main!StatusBar.Caption = "Printing To Window has failed."
Else
Main!StatusBar.Caption = "Printing to Window was successful."
End If
Main!StatusBar.Caption = " Active Window :- " & C.Caption
MenuFileClose.Enabled = True
Screen.MousePointer = 0
Exit Sub
ErrrHandler:
PECloseEngine
Exit Sub
End Sub
Sub MenuFilePrinter_Click ()
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
PrintFrm.Show 1
End Sub
Sub MenuFileWindow_Click ()
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
WinFrm.Show 1
End Sub
Sub MenuFormatGraph_Click ()
Graph.Show 1
End Sub
Sub MenuFormatGroupCond_Click ()
GroupCond.Show 1
End Sub
Sub MenuFormatMinSectionHeight_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuFormatRptTitle_Click ()
RPTTITLE.Show 1
End Sub
Sub MenuFormatSection_Click ()
Section.Show 1
End Sub
Sub MenuFormatSetLineHeight_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuFormatSetMargins_Click ()
MsgBox "Not Yet Implemented!"
End Sub
Sub MenuFormatSetSecFormat_Click ()
Section.Show
End Sub
Sub MenuFormatSetSectionFont_Click ()
'Invoke common dialogue to choose a report file name
'CMDialog1.Action = 4
Font.Show
End Sub
Sub MenuFormulaGroupSel_Click ()
SetFormula.Show
End Sub
Sub MenuFormulasGroupSel_Click ()
SetFormula.Show 1
End Sub
Sub MenuFormulasSetFormula_Click ()
SetFormula.Show 1
End Sub
Sub MenuFormulasSetSelForm_Click ()
SetFormula.Show 1
End Sub
Sub MenuGroupCond_Click ()
GroupCond.Show
End Sub
Sub MenuHelpAbout_Click ()
About.Show 1
End Sub
Sub MenuHelpCRWHLP_Click ()
RCode = Shell("Winhelp c:\crw\crw.hlp", 3)
End Sub
Sub MenuHelpWhere_Click ()
'Declarations
Dim Response As Integer
Dim RCode As Integer
'Allow user to open CRPEDEMO.TXT file if they choose.
'If the user chooses yes from the message box they will automatically
'be shelled to notepad with the appropriate text file opened
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")
'Check to see if Resources are high enough to logon to the server
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
Dim logonInfo As PELogonInfo
logonInfo.StructSize = Len(logonInfo)
logonInfo.ServerName = "ODBCSQL" + Chr$(0)
logonInfo.DatabaseName = "pubs" + Chr$(0)
logonInfo.UserID = "tech" + Chr$(0)
logonInfo.Password = "tech" + Chr$(0)
If PELogOnServer("PDSODBC.DLL", logonInfo) = 1 Then
'Open the Crystal Reports Print engine(i.e CRPE.DLL)
'Return of True(1) or false(0)
On Error GoTo CRPEErrb
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
If PEOpenEngine() = False Then
Main!StatusBar.Caption = "The engine did not open"
Exit Sub
Else
Main!StatusBar.Caption = "The engine is now open"
'Activate open print job menu item
MenuEngineOpenJob.Enabled = True
'Activate close engine menu item
MenuEngineClose.Enabled = True
'Activate LogonServer menu item. To use PELogonServer
'you only need the engine to be open. Not the job the job as well.
MenuLogon.Enabled = True
'deactivate open engine menu item so that user doesn't open the engine twice
'opening the engine twice can cause GPFs in windows
MenuEngineOpen.Enabled = False
MenuFileNew.Enabled = False
OpenEngButton.Enabled = False
OpenJobButton.Enabled = True
End If
'Check to see if Print job already exists
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job is already open"
End If
Exit Sub
CRPEErrb:
MsgBox "Cannot find CRPE.DLL in your Path! Please exit the application and add the directory containing this DLL to your DOS path."
Exit Sub
End Sub
Sub OpenJobbutton_Click ()
'Declarations
Dim Counter As Integer, Counter1 As Integer
'Constants
Counter = 0
Counter1 = 0
'Check to see if Resources are high enough to open the print job
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
'Invoke common dialogue to choose a report file name
On Error GoTo ErrorHandlerb
CmDialog1.CancelError = True
CmDialog1.Flags = OFN_HIDEREADONLY
CmDialog1.DialogTitle = "Open Report"
CmDialog1.Filter = "Crystal Reports (*.rpt)"
CmDialog1.Filename = "*.rpt"
CmDialog1.Action = 1
'Open Print job using specified file name. The return value
'is either true(1) or false(0)
If CmDialog1.Filename <> "" Then
Jobnum = PEOpenPrintJob(CmDialog1.Filename)
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job opened."
'Activate all menu items once job is opened
MenuFileNew.Enabled = False
MenuFilePrint.Enabled = True
MenuFilePrinter.Enabled = True
MenuFileWindow.Enabled = True
MenuFileFile.Enabled = True
MenuFileExport.Enabled = True
MenuEngineCloseJob.Enabled = True
MenuFormatRPTTitle.Enabled = True
MenuFormatSection.Enabled = True
MenuFormatGroupCond.Enabled = True
MenuFormatGraph.Enabled = True
MenuFieldsRecordSortField.Enabled = True
MenuFieldsGroupSortFields.Enabled = True
MenuFormulasSetFormula.Enabled = True
MenuFormulasSetSelForm.Enabled = True
MenuFormulasGroupSel.Enabled = True
MenuDBLocation.Enabled = True
MenuLogonInfo.Enabled = True
MenuSecurity.Enabled = True
MenuWindowCascade.Enabled = True
MenuWindowTileH.Enabled = True
MenuWindowTileV.Enabled = True
MenuWindowArrange.Enabled = True
PreviewButton.Enabled = True
PrintButton.Enabled = True
SelectionButton.Enabled = True
SortButton.Enabled = True
GroupCondButton.Enabled = True
HelpButton.Enabled = True
GraphButton.Enabled = True
FormulaButton.Enabled = True
FormatButton.Enabled = True
ExportButton.Enabled = True
Else
Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
End If
End If
'Determine what type of report(i.e. SQL or PC type) and then
'Enable or Disable the SQL Menu Items
'Declarations
Dim TableType As PETableType
'Define Structure
TableType.StructSize = Len(TableType)
TableType.DLLName = Chr$(0)
TableType.DescriptiveName = Chr$(0)
'TableType.DBType
'Determine number of tables in report
NTables = PEGetNTables(Jobnum)
'Get the table type based on the specific table names
For I = 0 To NTables - 1
If PEGetNthTableType(Jobnum, I, TableType) = False Then
'Database types are returned as either 0 or 1. Return a more
'descriptive message to the message box
If TableType.DBType = 1 Then
Counter = Counter + 1
Else
Counter1 = Counter1 + 1
End If
End If
Next I
If Counter1 > 0 Then
MenuSQLModify.Enabled = True
MenuSQLStoredProc.Enabled = True
SQLButton.Enabled = True
End If
ErrorHandlerb:
Exit Sub
End Sub
Sub Preview_Click ()
Dim C As New Child
Dim Jobnum As Integer
'Open the Crystal Reports Print engine(i.e CRPE.DLL)
'Return of True(1) or false(0)
If PEOpenEngine() = False Then
Main!StatusBar.Caption = "The engine did not open"
Else
Main!StatusBar.Caption = "The engine is now open"
End If
'Check to see if Print job already exists
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job is already open"
End If
'Invoke common dialogue to choose a report file name
CmDialog1.Action = 1
'Open Print job using specified file name. The return value
'is either true(1) or false(0)
If CmDialog1.Filename <> "" Then
Jobnum = PEOpenPrintJob(CmDialog1.Filename)
If Jobnum <> 0 Then
Main!StatusBar.Caption = "Job opened."
Else
Main!StatusBar.Caption = "Error = " & Str$(Jobnum) + " occured while trying to open the print job"
End If
End If
'Set the report window handle equal to that of the MDI child
'form so that our print window prints inside of the Window frame
'created by the Windows API call
Report_ParentWindowHandle = C.hWnd
Screen.MousePointer = 11
C.Caption = "MDIChild - " & Forms.Count
'Set the border style of the print window so that it has no border,max or min
'buttons, control box etc.
'Border_style% = 268435456
'Send the Print job to be printed to a window
If PEOutPutToWindow(Jobnum, C.Caption, ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight, 268435456, C.hWnd) = False Then
Main!StatusBar.Caption = "Output to Window has failed."
Else
Main!StatusBar.Caption = "Output to Window was successful."
End If
'Starts the desired print job
If PEStartPrintJob(Jobnum, True) = False Then
Main!StatusBar.Caption = "Printing To Window has failed."
Else
Main!StatusBar.Caption = "Printing to Window was successful."
End If
Main!StatusBar.Caption = " Active Window :- " & C.Caption
MenuFileClose.Enabled = True
Screen.MousePointer = 0
End Sub
Sub Previewbutton_Click ()
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
WinFrm.Show 1
End Sub
Sub PrintButton_Click ()
'Check to see if Resources are high enough to open the print engine
'Never let the user drop below 20% resources. If they do they ask them
'to exit the application, close other applications down, and try running
'CRPEDemo again
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
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."
Exit Sub
End If
PrintFrm.Show 1
End Sub
Sub SelectionButton_Click ()
SetFormula.Show 1
End Sub
Sub SortButton_Click ()
Sort.Show 1
End Sub
Sub SQLButton_Click ()
SQLQuery.Show 1
End Sub
Sub Timer1_Timer ()
Dim curhWnd As Integer 'Current hWnd
Dim p As POINTAPI
Static LasthWnd As Integer 'Hold previous hWnd
' Make sure the program has the input focus:
If GetActiveWindow() = Main.hWnd Then
' Initialize point structure:
Call GetCursorPos(p)
' Which window is the mouse cursor over?
curhWnd = WindowFromPoint(p.y, p.x)
' Same as last window? If so, don't need to redraw:
If curhWnd <> LasthWnd Then
' Store the current hWnd:
LasthWnd = curhWnd
' Decrease timer interval to 5 ms (could choose 1 ms):
Timer1.Interval = 5
' Which control is the cursor over?
Select Case curhWnd
Case OpenEngButton.hWnd
DisplayHelp "Open Engine"
Case OpenJobButton.hWnd
DisplayHelp "Open Print Job"
Case PreviewButton.hWnd
DisplayHelp "Print Preview"
Case PrintButton.hWnd
DisplayHelp "Print"
Case ExportButton.hWnd
DisplayHelp "Export"
Case FormatButton.hWnd
DisplayHelp "Format Section"
Case GraphButton.hWnd
DisplayHelp "Format Graph"
Case GroupCondButton.hWnd
DisplayHelp "Group Condition"
Case SortButton.hWnd
DisplayHelp "Sort"
Case FormulaButton.hWnd
DisplayHelp "Formula"
Case SelectionButton.hWnd
DisplayHelp "Selection Formula"
Case HelpButton.hWnd
DisplayHelp "Crystal Reports Help"
Case SQLButton.hWnd
DisplayHelp "Modify SQL"
'Case GetWindow(Combo1.hWnd, GW_CHILD) 'Edit box of combo box