home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch26code
/
listings
/
26lst05.txt
< prev
next >
Wrap
Text File
|
1995-08-01
|
11KB
|
229 lines
'*********************************************************************
' MDIOLE.FRM - MDI Parent Form.
'*********************************************************************
Option Explicit
Private StartedExcel As Long
'*********************************************************************
' Saves the button image in imgHold, and inserts the down picture.
'*********************************************************************
Private Sub imgTools_MouseDown(Index As Integer, Button As Integer, _
Shift As Integer, X As Single, Y As Single)
imgHold.Picture = imgTools(Index).Picture
imgTools(Index).Picture = imgTools(Index + 1).Picture
End Sub
'*********************************************************************
' Updates the status bar.
'*********************************************************************
Private Sub imgTools_MouseMove(Index As Integer, Button As Integer, _
Shift As Integer, X As Single, Y As Single)
UpdateStatus lblStatus, imgTools(Index).Tag
End Sub
'*********************************************************************
' Restores the graphic, and processes toolbar clicks.
'*********************************************************************
Private Sub imgTools_MouseUp(Index As Integer, Button As Integer, _
Shift As Integer, X As Single, Y As Single)
'*****************************************************************
' Restore the toolbar picture.
'*****************************************************************
imgTools(Index).Picture = imgHold.Picture
'*****************************************************************
' Execute the appropriate toolbar action.
'*****************************************************************
Select Case Index
Case 0 ' Hand
Unload Me
Case 2 ' Question Mark
'*************************************************************
' Bring up the splash form again, because the first OLE
' Automation call will require Excel to be started. After
' it is started, any subsequent calls will be peformed
' as fast as they would be in a native Excel macro.
'*************************************************************
frmSplash.lblMessage = _
"Gathering OLE Automation information from Excel...Please Wait!"
frmSplash.Show
frmSplash.Refresh
'*************************************************************
' Load the info dialog, and start printing to it.
'*************************************************************
Load frmInfo
'*************************************************************
' NOTE: Using the OLE Container's Object property, you can
' execute OLE Automation statements on the object in
' the control.
'*************************************************************
' Using 2 .Parent properties, allows you to access Excel's
' Application object.
'*************************************************************
PrintMessage "Application Name:", _
ActiveForm.Excel(0).Object.Parent.Parent.Name & " " & _
ActiveForm.Excel(0).Object.Parent.Parent.Version
PrintMessage "Operating System:", _
ActiveForm.Excel(0).Object.Parent.Parent.OperatingSystem
PrintMessage "Organization Name:", _
ActiveForm.Excel(0).Object.Parent.Parent.OrganizationName
'*************************************************************
' By default, the Object property points to a Worksheet.
'*************************************************************
PrintMessage "Range(""A2""):", _
ActiveForm.Excel(0).Object.Range("A2")
'*************************************************************
' Using 1 call to Parent, allows you to access Excel's
' Workbook object.
'*************************************************************
PrintMessage "Read Only:", _
ActiveForm.Excel(0).Object.Parent.ReadOnly
PrintMessage "Saved:", _
ActiveForm.Excel(0).Object.Parent.Saved
PrintMessage "Sheet Name:", _
ActiveForm.Excel(0).Object.Name
PrintMessage "Workbook Author:", _
ActiveForm.Excel(0).Object.Parent.Author
PrintMessage "Workbook Name:", _
ActiveForm.Excel(0).Object.Parent.Name
'*************************************************************
' Make sure all activity is complete, before unloading the
' the splash.
'*************************************************************
DoEvents
Unload frmSplash
'*************************************************************
' Display the information to the user.
'*************************************************************
frmInfo.Show 1
End Select
End Sub
'*********************************************************************
' Print the formatted string to frmInfo.
'*********************************************************************
Private Sub PrintMessage(Item As String, Result As Variant)
Dim LeftStr As String * 20, RightStr As String * 30
LeftStr = Item
RightStr = Result
frmInfo.Print LeftStr & RightStr
End Sub
'*********************************************************************
' Prepares the application for use.
'*********************************************************************
Private Sub MDIForm_Load()
Dim XLPath$
'*****************************************************************
' Always use the system defined backcolor.
'*****************************************************************
BackColor = vb3DFace
StatusBar.BackColor = vb3DFace
Toolbar.BackColor = vb3DFace
'*****************************************************************
' If necessary, start Excel to prevent annoying message boxes.
'*****************************************************************
XLPath = GetINI("Microsoft Excel", "cbtlocation", _
"c:\excel\excelcbt", "excel5.ini")
XLPath = Left(XLPath, Len(XLPath) - 8) & "excel.exe"
StartedExcel = StartServer("XLMAIN", XLPath)
WindowState = 2 'Maximized
frmExcel.Show
Arrange vbTileHorizontal
End Sub
'*********************************************************************
' Updates the status bar with the default text.
'*********************************************************************
Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
UpdateStatus lblStatus
End Sub
'*********************************************************************
' If you had to start Excel, then close it. Otherwise, leave it alone.
'*********************************************************************
Private Sub MDIForm_Unload(Cancel As Integer)
If StartedExcel <> False Then
CloseApp StartedExcel
End If
End Sub
'*********************************************************************
' Terminates the application.
'*********************************************************************
Private Sub mnuFileItems_Click(Index As Integer)
Unload Me
End Sub
'*********************************************************************
' Updates the status bar with the default text.
'*********************************************************************
Private Sub StatusBar_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
UpdateStatus lblStatus
End Sub
'*********************************************************************
' Adds a 3D appearance to the status bar.
'*********************************************************************
Private Sub StatusBar_Paint()
HighlightBar StatusBar
Highlight lblStatus
End Sub
'*********************************************************************
' Updates the status bar with the default text.
'*********************************************************************
Private Sub Toolbar_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
UpdateStatus lblStatus
End Sub
'*********************************************************************
' Adds a 3D appearance to the toolbar.
'*********************************************************************
Private Sub Toolbar_Paint()
HighlightBar Toolbar
End Sub
'*********************************************************************
' Adds a 3D effect to a picture box.
'*********************************************************************
Private Sub HighlightBar(Bar As PictureBox)
Bar.Line (0, 5)-(Bar.ScaleWidth, 5), vb3DHighlight
Bar.Line (0, Bar.ScaleHeight - 15)-(Bar.ScaleWidth, _
Bar.ScaleHeight - 15), vb3DShadow
End Sub
'*********************************************************************
' Adds a 3D border around a control.
'*********************************************************************
Private Sub Highlight(Object As Control)
Const HORIZONTAL_OFFSET = 50
Const VERTICAL_OFFSET = 70
'*****************************************************************
' Top
'*****************************************************************
StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
Object.Top - HORIZONTAL_OFFSET)- _
(Object.Width, _
Object.Top - HORIZONTAL_OFFSET), _
vb3DShadow
'*****************************************************************
' Left
'*****************************************************************
StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
Object.Top - HORIZONTAL_OFFSET)- _
(Object.Left - HORIZONTAL_OFFSET, _
Object.Height + VERTICAL_OFFSET), _
vb3DShadow
'*****************************************************************
' Bottom
'*****************************************************************
StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
Object.Height + VERTICAL_OFFSET)- _
(Object.Width, _
Object.Height + VERTICAL_OFFSET), _
vb3DHighlight
'*****************************************************************
' Right
'*****************************************************************
StatusBar.Line (Object.Width, _
Object.Top - HORIZONTAL_OFFSET)- _
(Object.Width, _
Object.Height + VERTICAL_OFFSET + 15), _
vb3DHighlight
End Sub