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 >
Wrap
Text File
|
1995-08-14
|
2KB
|
85 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Windows"
Attribute VB_Creatable = False
Attribute VB_Exposed = True
Option Explicit
' Create a Windows collection
Private colWindows As New Collection
' Windows object Application property
Public Property Get Application()
Set Application = modDeclares.Application
End Property
' Windows Add method -- verifies object type
' before adding an object to the collection.
Sub Add(Optional winVal, Optional Key, Optional Before, Optional After)
Attribute Add.VB_HelpID = 1234
Attribute Add.VB_Description = "Add method"
' If no form is specified, create a new form.
If IsMissing(winVal) Then
' Create a new instance of the Window class.
Dim Window As New Window
' Tell the Window to create itself and
' add it to the collection.
colWindows.Add _
Window.Create(SOURCE_INTERNAL), _
Window.Index
Exit Sub
End If
' If the object is a form, add it to
' the collection.
If TypeName(winVal) = "Window" Then
' Make sure object has been initialized.
If Len(winVal.Index) Then
colWindows.Add winVal, Key, Before, After
' If it hasn't, use the Create function to create it.
Else
colWindows.Add _
winVal.Create(SOURCE_INTERNAL), _
winVal.Index
End If
' Cause a type mismatch error.
Else
Error 13
End If
End Sub
' Standard Remove method.
Sub Remove(Index)
' Delete the form -- SOURCE_INTERNAL argument
' indicates that Delete is used internally, so
' Remove is not called to remove the Window from
' the collection (causing infinite loop).
If colWindows.Count Then
colWindows.Item(Index).Delete SOURCE_INTERNAL
' Remove the object from the collection.
colWindows.Remove Index
End If
End Sub
' Standard Item method.
Function Item(Index) As Object
' Use the Set statement to return an object
' reference. Simple assignment would return
' the default property for the object
Set Item = colWindows.Item(Index)
End Function
' Standard Count property.
Property Get Count() As Integer
Count = colWindows.Count
End Property
' Arrange all of the child windows in the
' MDI parent.
Sub Arrange(arrangement As Integer)
mdiApplication.Arrange arrangement
End Sub