home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmMain
- AutoRedraw = -1 'True
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- Caption = "UseAll Main Window"
- ClientHeight = 3495
- ClientLeft = 1140
- ClientTop = 1560
- ClientWidth = 7365
- Height = 3900
- Icon = "FRMMAIN.frx":0000
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 233
- ScaleMode = 3 'Pixel
- ScaleWidth = 491
- Top = 1215
- Width = 7485
- Begin VB.PictureBox picButton
- Appearance = 0 'Flat
- AutoRedraw = -1 'True
- BackColor = &H00C0C0C0&
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 735
- Index = 0
- Left = 4725
- ScaleHeight = 47
- ScaleMode = 3 'Pixel
- ScaleWidth = 50
- TabIndex = 1
- TabStop = 0 'False
- Top = 495
- Width = 780
- End
- Begin VB.Label lblStatus
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Click to update the chart!"
- Height = 195
- Left = 4905
- TabIndex = 5
- Top = 1485
- UseMnemonic = 0 'False
- Visible = 0 'False
- Width = 1230
- End
- Begin VB.OLE oleExcel
- BackStyle = 0 'Transparent
- BorderStyle = 0 'None
- Class = "Excel.Sheet.5"
- Height = 3345
- Left = 4875
- OleObjectBlob = "FRMMAIN.frx":030A
- SizeMode = 1 'Stretch
- SourceDoc = "d:\book\submit\chpx6\code\qrybugs.xls"
- TabIndex = 4
- TabStop = 0 'False
- Top = 3675
- Width = 4530
- End
- Begin VB.Label lbl
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Command Console"
- BeginProperty Font
- name = "Times New Roman"
- charset = 0
- weight = 700
- size = 13.5
- underline = 0 'False
- italic = -1 'True
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H0000FFFF&
- Height = 330
- Left = 4680
- TabIndex = 0
- Top = 180
- Width = 2175
- End
- Begin MSComDlg.CommonDialog cdlg
- Left = 5670
- Top = 540
- _Version = 65536
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 0
- CancelError = -1 'True
- DefaultExt = "frm"
- DialogTitle = "View Code in Word 6.0"
- Filter = "VB Code (*.bas, *.cls, *.frm)|*.bas;*.cls;*.frm|All Files (*.*)|*.*"
- FilterIndex = 1
- End
- Begin VB.OLE olePower
- BackStyle = 0 'Transparent
- Class = "PowerPoint.Show.7"
- Height = 3405
- Left = 180
- OleObjectBlob = "FRMMAIN.frx":3922
- SizeMode = 1 'Stretch
- SourceDoc = "d:\book\submit\chpx6\code\useall.ppt"
- TabIndex = 3
- TabStop = 0 'False
- Top = 3615
- Width = 4455
- End
- Begin VB.OLE oleProject
- BackStyle = 0 'Transparent
- BorderStyle = 0 'None
- Height = 3255
- Left = 180
- OleObjectBlob = "FRMMAIN.frx":18B3A
- SizeMode = 1 'Stretch
- SourceDoc = "e:\proj\softdev.mpp"
- TabIndex = 2
- TabStop = 0 'False
- Top = 180
- Width = 4455
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- '*********************************************************************
- ' FRMMAIN.FRM - This is command central where everything begins.
- '*********************************************************************
- Option Explicit
- Public clsR2XL As New clsReportToXL
- Public clsPPrint As New clsPrettyPrint
- #If Win32 Then
- Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As _
- Long, ByVal nIndex As Long) As Long
- #Else
- Private Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC%, _
- ByVal nIndex%) As Integer
- #End If
- '*********************************************************************
- ' This is a form level conditional compilation constant. It's used to
- ' prevent performing certain time consuming tasks during debugging.
- '*********************************************************************
- #Const DEBUG_MODE = False
- '*********************************************************************
- ' Position and size all objects on the form.
- '*********************************************************************
- Private Sub Form_Load()
- Dim Quad2 As RECT, Quad4 As RECT, NewQuad As RECT, i%
- '*****************************************************************
- ' Since these are time consuming to display, hide them during
- ' debugging.
- '*****************************************************************
- #If DEBUG_MODE Then
- oleExcel.Visible = False
- olePower.Visible = False
- oleProject.Visible = False
- #End If
- '*****************************************************************
- ' Change Backcolor and Display the splash screen.
- '*****************************************************************
- On Error Resume Next
- picButton(0).BackColor = vb3DFace
- BackColor = vb3DFace
- SplashVisible True
- '*****************************************************************
- ' Size the form to the screen.
- '*****************************************************************
- Move 0, 0, Screen.Width, Screen.Height
- '*****************************************************************
- ' Draw a 3d grid on the form.
- '*****************************************************************
- Draw3DGrid Me, True
- '*****************************************************************
- ' Position a label above the oleExcel control.
- '*****************************************************************
- GetQuad 2, Quad2
- GetQuad 4, Quad4
- With NewQuad
- .rL = Quad2.rL
- .rT = Quad2.rB
- .rR = Quad2.rR
- .rB = Quad4.rT
- End With
- SizeToRectClient lblStatus, NewQuad
- '*****************************************************************
- ' Draw a DkBlue background in Quad2 & position lbl and picButtons.
- '*****************************************************************
- ResizeRect Quad2, -1, -1, False
- DrawRect Me, Quad2, Solid:=True, RectColor:=RGB(0, 0, 64)
- SizeToRectClient lbl, Quad2
- lbl.top = Quad2.rT + 2
- lbl.Height = GetRectHeight(Quad2) * 0.1
- picButton(0).Move lbl.Left + 50, lbl.top + lbl.Height, _
- lbl.Width - 100, GetRectHeight(Quad2) * 0.2
- '*****************************************************************
- ' Load 3 more buttons 5 pixels apart.
- '*****************************************************************
- For i = 1 To 3
- Load picButton(i): picButton(i).Visible = True
- picButton(i).top = picButton(i - 1).top + _
- picButton(i - 1).Height + 5
- Next i
- '*****************************************************************
- ' Create the button effect, and label them.
- '*****************************************************************
- picButton(0).Tag = "Create a Bug Report..." & "|ADD_BUGS"
- Handle_MouseUpDown 0, False
- Handle_MouseUpDown 1, False
- Handle_MouseUpDown 2, False
- Handle_MouseUpDown 3, False
- '*****************************************************************
- ' Make sure everything is positioned, then remove the splash form.
- '*****************************************************************
- VerifyControlPositions
- Visible = True
- SplashVisible False
- End Sub
- '*********************************************************************
- ' Resizing OLE Controls can be VERY time consuming, so only do it if
- ' they have moved, or if resolution is <> 640x480.
- '*********************************************************************
- Sub VerifyControlPositions()
- Const HORZRES = 8 ' Horizontal width in pixels
- Const VERTRES = 10 ' Vertical width in pixels
- Dim hRes%, vRes%, Quad1 As RECT, Quad3 As RECT, Quad4 As RECT
- '*****************************************************************
- ' Get the size of the quadrants.
- '*****************************************************************
- GetQuad 1, Quad1
- GetQuad 3, Quad3
- GetQuad 4, Quad4
- '*****************************************************************
- ' Get the screen resolution,
- '*****************************************************************
- hRes = GetDeviceCaps(hDC, HORZRES)
- vRes = GetDeviceCaps(hDC, VERTRES)
- '*****************************************************************
- ' If not 640x480, then resize the OLE controls.
- '*****************************************************************
- If hRes <> 640 Or vRes <> 480 Then
- SizeToRectClient oleProject, Quad1
- SizeToRectClient olePower, Quad3
- SizeToRectClient oleExcel, Quad4
- '*****************************************************************
- ' If ole??? has moved or been resized, then fix it.
- '*****************************************************************
- ElseIf Not EqualToQuadClient(oleProject, Quad1) Then
- SizeToRectClient oleProject, Quad1
- ElseIf Not EqualToQuadClient(olePower, Quad3) Then
- SizeToRectClient olePower, Quad3
-
- ElseIf Not EqualToQuadClient(oleExcel, Quad4) Then
- SizeToRectClient oleExcel, Quad4
- End If
- '*****************************************************************
- ' Process the delays caused by resizing OLE controls.
- '*****************************************************************
- DoEvents
- End Sub
- '*********************************************************************
- ' Make sure there are no orphan forms.
- '*********************************************************************
- Private Sub Form_Unload(Cancel As Integer)
- Unload frmReturn
- End Sub
- '*********************************************************************
- ' If the mouse is over the form, then hide lblStatus.
- '*********************************************************************
- Private Sub Form_MouseMove(Button%, Shift%, x As Single, y As Single)
- lblStatus.Visible = False
- End Sub
- '*********************************************************************
- ' Update the chart whenever the user clicks on it.
- '*********************************************************************
- Private Sub oleExcel_Click()
- UpdateChart
- End Sub
- '*********************************************************************
- ' If the mouse is over the control, then show the label.
- '*********************************************************************
- Private Sub oleExcel_MouseMove(Button%, Shift%, x As Single, y As Single)
- lblStatus.Visible = True
- End Sub
- '*********************************************************************
- ' Performs the appropriate action for the picButton that was clicked.
- '*********************************************************************
- Private Sub picButton_Click(Index As Integer)
- '*****************************************************************
- ' Since a Click event only occurs when an object gets a Mouse_Down
- ' AND a Mouse_Up event, all command processing should be here.
- '*****************************************************************
- On Error Resume Next
- Select Case Index
- Case 0
- frmBugs.Show vbModal
- Case 1
- '*********************************************************
- ' Display frmReturn by calling its Display method, instead
- ' of using the Show method. This allows frmReturn to know
- ' which form is requesting that frmReturn is displayed.
- ' This is important because frmReturn needs to know which
- ' form it should activate when it is unloaded.
- '*********************************************************
- frmReturn.Display Me
- clsR2XL.ReportToExcel App.Path & "\bugs.mdb"
- Case 2
- '*********************************************************
- ' Display a common file open dialog.
- '*********************************************************
- cdlg.FLAGS = cdlOFNFileMustExist + cdlOFNHideReadOnly + _
- cdlOFNPathMustExist
- cdlg.ShowOpen
- If Err <> cdlCancel Then
- frmReturn.Display Me
- clsPPrint.PrettyPrint cdlg.FileName
- End If
- Case 3
- Unload Me
- End Select
- End Sub
- '*********************************************************************
- ' This method is called by frmReturn after frmMain has been made
- ' visible. This method is used to destroy references to any OLE
- ' Automation objects.
- '*********************************************************************
- Public Sub DestroyObject()
- Set clsPPrint = Nothing
- Set clsR2XL = Nothing
- End Sub
- '*********************************************************************
- ' These two events simulate the button clicking effect.
- '*********************************************************************
- Private Sub picButton_MouseDown(Index%, Button%, Shift%, x!, y!)
- Handle_MouseUpDown Index, True
- End Sub
- Private Sub picButton_MouseUp(Index%, Button%, Shift%, x!, y!)
- Handle_MouseUpDown Index, False
- End Sub
- '*********************************************************************
- ' A single Procedure is used so that the code only appears in one
- ' place. This prevents errors from duplicate code.
- '*********************************************************************
- Private Sub Handle_MouseUpDown(Index%, bState As Boolean)
- '*****************************************************************
- ' Here's where all of buttons are drawn. Any changes here will
- ' affect all other procedures which operate on picButtons.
- '*****************************************************************
- Select Case Index
- Case 0
- DrawButton picButton(Index), IsDown:=bState, _
- IsResource:=True
- Case 1
- DrawButton picButton(1), IsDown:=bState, _
- sCaption:="Bug Summary in Excel...", _
- sIcon:="VIEW_BUGS", _
- IsResource:=True
- Case 2
- DrawButton picButton(2), IsDown:=bState, _
- sCaption:="View Code in Word...", _
- sIcon:="VIEW_CODE", _
- IsResource:=True
- Case 3
- DrawButton picButton(3), IsDown:=bState, _
- sCaption:="Exit Application...", _
- sIcon:="EXIT", _
- IsResource:=True
- End Select
- End Sub
- Private Sub UpdateChart()
- Dim BugDBase As New GenericDB, retArray() As String
- BugDBase.OpenDB App.Path & "\bugs.mdb"
- BugDBase.CreateRecordSet "qryBugsByProduct"
- BugDBase.GetArrayData "BugCount", retArray()
- oleExcel.DoVerb 0
- With oleExcel.object.Parent.Parent.ActiveWorkbook
- .Sheets("Bugs").Range("B2").FormulaR1C1 = retArray(0)
- .Sheets("Bugs").Range("B3").FormulaR1C1 = retArray(1)
- .Sheets("Bugs").Range("B4").FormulaR1C1 = retArray(2)
- End With
- oleExcel.Close
- Set BugDBase = Nothing
- End Sub
-