' 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 ()
'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
'Show export form
Export.Show 1
End Sub
Sub FormatButton_Click ()
'Section.Show 1
End Sub
Sub FormulaButton_Click ()
SetFormula.Show 1
End Sub
Sub Graphbutton_Click ()
Graph.Show 1
End Sub
Sub GroupCondButton_Click ()
'GroupCond.Show 1
End Sub
Sub HelpButton_Click ()
RCode = Shell("Winhelp c:\crw\crw.hlp", 3)
End Sub
Sub MDIForm_Load ()
' Set timer for 1 second, and enable it.
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Sub MDIForm_Resize ()
Line1.X2 = Me.ScaleWidth
Line2.X2 = Me.ScaleWidth
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 ()
End Sub
Sub MenuEngineCloseJob_Click ()
End Sub
Sub MenuEngineOpen_Click ()
End Sub
Sub MenuEngineOpenJob_Click ()
End Sub
Sub MenuFieldsGroupSortFields_Click ()
Sort.Show 1
End Sub
Sub MenuFieldsRecordSortField_Click ()
Sort.Show 1
End Sub
Sub MenuFileClose_Click ()
If Forms.Count > 2 Then
Unload ActiveForm
If Forms.Count = 1 Then
MenuFileClose.Enabled = False
End If
End If
End Sub
Sub MenuFileExit_Click ()
End
End Sub
Sub MenuFileExport_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
'Show export form
Export.Show 1
End Sub
Sub MenuFileNew_Click ()
Dim C As New Child
'Invoke common dialogue to choose a report file name
'Invoke common dialogue to choose a report file name
On Error GoTo ErrorHandler1
CmDialog1.CancelError = True
CmDialog1.Flags = OFN_HIDEREADONLY
CmDialog1.DialogTitle = "Open Report"
CmDialog1.Filter = "Crystal Reports (*.rpt)"
CmDialog1.Filename = "*.rpt"
CmDialog1.Action = 1
'Specify a Report Filename
If CmDialog1.Filename <> "" Then
Main.Report1.ReportFileName = CmDialog1.Filename
Main!StatusBar.Caption = "Report Opened."
MenuFilePrint.Enabled = True
MenuFilePrinter.Enabled = True
MenuFileWindow.Enabled = True
MenuFileExport.Enabled = True
MenuFormatRPTTitle.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
HelpButton.Enabled = True
GraphButton.Enabled = True
FormulaButton.Enabled = True
ExportButton.Enabled = True
SQLButton.Enabled = True
End If
Exit Sub
ErrorHandler1:
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 the VBX properties is included in the VBXDEMO.TXT. Would you like to view the text file now?", 4, "VBX Properties List")
'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
'Specify a Report Filename
If CmDialog1.Filename <> "" Then
Report1.ReportFileName = CmDialog1.Filename
Main!StatusBar.Caption = "Report Opened."
'Activate all menu items once job is opened
MenuFilePrint.Enabled = True
MenuFilePrinter.Enabled = True
MenuFileWindow.Enabled = True
MenuFileExport.Enabled = True
MenuFormatRPTTitle.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
MenuSQLModify.Enabled = True
MenuSQLStoredProc.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
HelpButton.Enabled = True
GraphButton.Enabled = True
FormulaButton.Enabled = True
ExportButton.Enabled = True
SQLButton.Enabled = True
Else
MsgBox "An error occured trying Open a Report."
End If
Exit Sub
ErrorHandlerb:
Exit Sub
End Sub
Sub Preview_Click ()
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 OpenJobButton.hWnd
DisplayHelp "Open Print Job"
Case PreviewButton.hWnd
DisplayHelp "Print Preview"
Case PrintButton.hWnd
DisplayHelp "Print"
Case ExportButton.hWnd
DisplayHelp "Export"
Case GraphButton.hWnd
DisplayHelp "Format Graph"
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