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 >
Text File  |  1995-08-01  |  11KB  |  229 lines

  1. '*********************************************************************
  2. ' MDIOLE.FRM - MDI Parent Form.
  3. '*********************************************************************
  4. Option Explicit
  5. Private StartedExcel As Long
  6. '*********************************************************************
  7. ' Saves the button image in imgHold, and inserts the down picture.
  8. '*********************************************************************
  9. Private Sub imgTools_MouseDown(Index As Integer, Button As Integer, _
  10.                            Shift As Integer, X As Single, Y As Single)
  11.     imgHold.Picture = imgTools(Index).Picture
  12.     imgTools(Index).Picture = imgTools(Index + 1).Picture
  13. End Sub
  14. '*********************************************************************
  15. ' Updates the status bar.
  16. '*********************************************************************
  17. Private Sub imgTools_MouseMove(Index As Integer, Button As Integer, _
  18.                            Shift As Integer, X As Single, Y As Single)
  19.     UpdateStatus lblStatus, imgTools(Index).Tag
  20. End Sub
  21. '*********************************************************************
  22. ' Restores the graphic, and processes toolbar clicks.
  23. '*********************************************************************
  24. Private Sub imgTools_MouseUp(Index As Integer, Button As Integer, _
  25.                          Shift As Integer, X As Single, Y As Single)
  26.     '*****************************************************************
  27.     ' Restore the toolbar picture.
  28.     '*****************************************************************
  29.     imgTools(Index).Picture = imgHold.Picture
  30.     '*****************************************************************
  31.     ' Execute the appropriate toolbar action.
  32.     '*****************************************************************
  33. Select Case Index
  34.     Case 0 ' Hand
  35.         Unload Me
  36.     Case 2 ' Question Mark
  37.         '*************************************************************
  38.         ' Bring up the splash form again, because the first OLE
  39.         ' Automation call will require Excel to be started. After
  40.         ' it is started, any subsequent calls will be peformed
  41.         ' as fast as they would be in a native Excel macro.
  42.         '*************************************************************
  43.         frmSplash.lblMessage = _
  44.         "Gathering OLE Automation information from Excel...Please Wait!"
  45.         frmSplash.Show
  46.         frmSplash.Refresh
  47.         '*************************************************************
  48.         ' Load the info dialog, and start printing to it.
  49.         '*************************************************************
  50.         Load frmInfo
  51.         '*************************************************************
  52.         ' NOTE: Using the OLE Container's Object property, you can
  53.         '       execute OLE Automation statements on the object in
  54.         '       the control.
  55.         '*************************************************************
  56.         ' Using 2 .Parent properties, allows you to access Excel's
  57.         ' Application object.
  58.         '*************************************************************
  59.         PrintMessage "Application Name:", _
  60.             ActiveForm.Excel(0).Object.Parent.Parent.Name & " " & _
  61.             ActiveForm.Excel(0).Object.Parent.Parent.Version
  62.         
  63.         PrintMessage "Operating System:", _
  64.             ActiveForm.Excel(0).Object.Parent.Parent.OperatingSystem
  65.         
  66.         PrintMessage "Organization Name:", _
  67.             ActiveForm.Excel(0).Object.Parent.Parent.OrganizationName
  68.         '*************************************************************
  69.         ' By default, the Object property points to a Worksheet.
  70.         '*************************************************************
  71.         PrintMessage "Range(""A2""):", _
  72.             ActiveForm.Excel(0).Object.Range("A2")
  73.         '*************************************************************
  74.         ' Using 1 call to Parent, allows you to access Excel's
  75.         ' Workbook object.
  76.         '*************************************************************
  77.         PrintMessage "Read Only:", _
  78.             ActiveForm.Excel(0).Object.Parent.ReadOnly
  79.         
  80.         PrintMessage "Saved:", _
  81.             ActiveForm.Excel(0).Object.Parent.Saved
  82.         
  83.         PrintMessage "Sheet Name:", _
  84.             ActiveForm.Excel(0).Object.Name
  85.         
  86.         PrintMessage "Workbook Author:", _
  87.             ActiveForm.Excel(0).Object.Parent.Author
  88.         
  89.         PrintMessage "Workbook Name:", _
  90.             ActiveForm.Excel(0).Object.Parent.Name
  91.         '*************************************************************
  92.         ' Make sure all activity is complete, before unloading the
  93.         ' the splash.
  94.         '*************************************************************
  95.         DoEvents
  96.         Unload frmSplash
  97.         '*************************************************************
  98.         ' Display the information to the user.
  99.         '*************************************************************
  100.         frmInfo.Show 1
  101. End Select
  102. End Sub
  103. '*********************************************************************
  104. ' Print the formatted string to frmInfo.
  105. '*********************************************************************
  106. Private Sub PrintMessage(Item As String, Result As Variant)
  107. Dim LeftStr As String * 20, RightStr As String * 30
  108.     LeftStr = Item
  109.     RightStr = Result
  110.     frmInfo.Print LeftStr & RightStr
  111. End Sub
  112. '*********************************************************************
  113. ' Prepares the application for use.
  114. '*********************************************************************
  115. Private Sub MDIForm_Load()
  116. Dim XLPath$
  117.     '*****************************************************************
  118.     ' Always use the system defined backcolor.
  119.     '*****************************************************************
  120.     BackColor = vb3DFace
  121.     StatusBar.BackColor = vb3DFace
  122.     Toolbar.BackColor = vb3DFace
  123.     '*****************************************************************
  124.     ' If necessary, start Excel to prevent annoying message boxes.
  125.     '*****************************************************************
  126.     XLPath = GetINI("Microsoft Excel", "cbtlocation", _
  127.              "c:\excel\excelcbt", "excel5.ini")
  128.     XLPath = Left(XLPath, Len(XLPath) - 8) & "excel.exe"
  129.     StartedExcel = StartServer("XLMAIN", XLPath)
  130.     WindowState = 2 'Maximized
  131.     frmExcel.Show
  132.     Arrange vbTileHorizontal
  133. End Sub
  134. '*********************************************************************
  135. ' Updates the status bar with the default text.
  136. '*********************************************************************
  137. Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, _
  138.                                             X As Single, Y As Single)
  139.     UpdateStatus lblStatus
  140. End Sub
  141. '*********************************************************************
  142. ' If you had to start Excel, then close it. Otherwise, leave it alone.
  143. '*********************************************************************
  144. Private Sub MDIForm_Unload(Cancel As Integer)
  145.     If StartedExcel <> False Then
  146.         CloseApp StartedExcel
  147.     End If
  148. End Sub
  149. '*********************************************************************
  150. ' Terminates the application.
  151. '*********************************************************************
  152. Private Sub mnuFileItems_Click(Index As Integer)
  153.     Unload Me
  154. End Sub
  155. '*********************************************************************
  156. ' Updates the status bar with the default text.
  157. '*********************************************************************
  158. Private Sub StatusBar_MouseMove(Button As Integer, Shift As Integer, _
  159.                                              X As Single, Y As Single)
  160.     UpdateStatus lblStatus
  161. End Sub
  162. '*********************************************************************
  163. ' Adds a 3D appearance to the status bar.
  164. '*********************************************************************
  165. Private Sub StatusBar_Paint()
  166.     HighlightBar StatusBar
  167.     Highlight lblStatus
  168. End Sub
  169. '*********************************************************************
  170. ' Updates the status bar with the default text.
  171. '*********************************************************************
  172. Private Sub Toolbar_MouseMove(Button As Integer, Shift As Integer, _
  173.                                             X As Single, Y As Single)
  174.     UpdateStatus lblStatus
  175. End Sub
  176. '*********************************************************************
  177. ' Adds a 3D appearance to the toolbar.
  178. '*********************************************************************
  179. Private Sub Toolbar_Paint()
  180.     HighlightBar Toolbar
  181. End Sub
  182. '*********************************************************************
  183. ' Adds a 3D effect to a picture box.
  184. '*********************************************************************
  185. Private Sub HighlightBar(Bar As PictureBox)
  186.     Bar.Line (0, 5)-(Bar.ScaleWidth, 5), vb3DHighlight
  187.     Bar.Line (0, Bar.ScaleHeight - 15)-(Bar.ScaleWidth, _
  188.                         Bar.ScaleHeight - 15), vb3DShadow
  189. End Sub
  190. '*********************************************************************
  191. ' Adds a 3D border around a control.
  192. '*********************************************************************
  193. Private Sub Highlight(Object As Control)
  194. Const HORIZONTAL_OFFSET = 50
  195. Const VERTICAL_OFFSET = 70
  196.     '*****************************************************************
  197.     ' Top
  198.     '*****************************************************************
  199.     StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
  200.                    Object.Top - HORIZONTAL_OFFSET)- _
  201.                    (Object.Width, _
  202.                    Object.Top - HORIZONTAL_OFFSET), _
  203.                    vb3DShadow
  204.     '*****************************************************************
  205.     ' Left
  206.     '*****************************************************************
  207.     StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
  208.                    Object.Top - HORIZONTAL_OFFSET)- _
  209.                    (Object.Left - HORIZONTAL_OFFSET, _
  210.                    Object.Height + VERTICAL_OFFSET), _
  211.                    vb3DShadow
  212.     '*****************************************************************
  213.     ' Bottom
  214.     '*****************************************************************
  215.     StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
  216.                    Object.Height + VERTICAL_OFFSET)- _
  217.                    (Object.Width, _
  218.                    Object.Height + VERTICAL_OFFSET), _
  219.                    vb3DHighlight
  220.     '*****************************************************************
  221.     ' Right
  222.     '*****************************************************************
  223.     StatusBar.Line (Object.Width, _
  224.                     Object.Top - HORIZONTAL_OFFSET)- _
  225.                    (Object.Width, _
  226.                    Object.Height + VERTICAL_OFFSET + 15), _
  227.                    vb3DHighlight
  228. End Sub
  229.