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 / ch19code / windows.cls < prev    next >
Text File  |  1995-08-14  |  2KB  |  85 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Windows"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. ' Create a Windows collection
  11. Private colWindows As New Collection
  12.  
  13. ' Windows object Application property
  14. Public Property Get Application()
  15.     Set Application = modDeclares.Application
  16. End Property
  17.  
  18. ' Windows Add method -- verifies object type
  19. ' before adding an object to the collection.
  20. Sub Add(Optional winVal, Optional Key, Optional Before, Optional After)
  21. Attribute Add.VB_HelpID = 1234
  22. Attribute Add.VB_Description = "Add method"
  23.     ' If no form is specified, create a new form.
  24.     If IsMissing(winVal) Then
  25.         ' Create a new instance of the Window class.
  26.         Dim Window As New Window
  27.         ' Tell the Window to create itself and
  28.         ' add it to the collection.
  29.         colWindows.Add _
  30.             Window.Create(SOURCE_INTERNAL), _
  31.             Window.Index
  32.         Exit Sub
  33.     End If
  34.     ' If the object is a form, add it to
  35.     ' the collection.
  36.     If TypeName(winVal) = "Window" Then
  37.         ' Make sure object has been initialized.
  38.         If Len(winVal.Index) Then
  39.             colWindows.Add winVal, Key, Before, After
  40.         ' If it hasn't, use the Create function to create it.
  41.         Else
  42.             colWindows.Add _
  43.                 winVal.Create(SOURCE_INTERNAL), _
  44.                 winVal.Index
  45.         End If
  46.     ' Cause a type mismatch error.
  47.     Else
  48.         Error 13
  49.     End If
  50. End Sub
  51.  
  52. ' Standard Remove method.
  53. Sub Remove(Index)
  54.     ' Delete the form -- SOURCE_INTERNAL argument
  55.     ' indicates that Delete is used internally, so
  56.     ' Remove is not called to remove the Window from
  57.     ' the collection (causing infinite loop).
  58.     If colWindows.Count Then
  59.         colWindows.Item(Index).Delete SOURCE_INTERNAL
  60.         ' Remove the object from the collection.
  61.         colWindows.Remove Index
  62.     End If
  63. End Sub
  64.  
  65. ' Standard Item method.
  66. Function Item(Index) As Object
  67.     ' Use the Set statement to return an object
  68.     ' reference. Simple assignment would return
  69.     ' the default property for the object
  70.     Set Item = colWindows.Item(Index)
  71. End Function
  72.  
  73. ' Standard Count property.
  74. Property Get Count() As Integer
  75.     Count = colWindows.Count
  76. End Property
  77.  
  78. ' Arrange all of the child windows in the
  79. ' MDI parent.
  80. Sub Arrange(arrangement As Integer)
  81.     mdiApplication.Arrange arrangement
  82. End Sub
  83.  
  84.  
  85.