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 / window.cls < prev    next >
Text File  |  1995-08-14  |  4KB  |  162 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Window"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. Private Window As frmWindow
  11.  
  12. Public Function Create(Optional iCode) As Object
  13.     If IsMissing(iCode) Then
  14.         Windows.Add Me
  15.     ' If source was within this project, don't
  16.     ' delegate to Windows.Remove.
  17.     ElseIf iCode = SOURCE_INTERNAL Then
  18.         ' Create window
  19.         Set Window = New frmWindow
  20.         ' Keep track of the total number of windows
  21.         ' ever created for Window Index property.
  22.         ' Can 't use Windows.Count, since deleting
  23.         ' windows yields a non-unique number.
  24.         giWindowsCount = giWindowsCount + 1
  25.         Window.Index = Str(giWindowsCount)
  26.         ' Display caption.
  27.         Window.Caption = "Window" & Window.Index
  28.         ' Register as the active window
  29.         Set modDeclares.gActiveWindow = Me
  30.         ' Return this object as the result of Create.
  31.         Set Create = Me
  32.     ' Otherwise, an invalid argument was used.
  33.     Else
  34.         ' Invalid procedure call error.
  35.         Error 5
  36.     End If
  37. End Function
  38.  
  39. ' Window delete method, unloads the form.
  40. Public Function Delete(Optional iCode)
  41.     ' Check source of Delete call -- if omitted,
  42.     ' delagate to Windows.Remove.
  43.     If IsMissing(iCode) Then
  44.         Windows.Remove Me
  45.     ' If source was within this project, don't
  46.     ' delegate to Windows.Remove.
  47.     ElseIf iCode = SOURCE_INTERNAL Then
  48.         Unload Window
  49.     ' Otherwise, an invalid argument was used.
  50.     Else
  51.         ' Invalid procedure call error.
  52.         Error 5
  53.     End If
  54. End Function
  55.  
  56. #If Win16 Then
  57. Public Property Get hWnd() As Integer
  58. #Else
  59. Public Property Get hWnd() As Long
  60. #End If
  61.     hWnd = Window.hWnd
  62. End Property
  63.  
  64. Public Property Get Name() As String
  65.     Name = Me.Caption
  66. End Property
  67.  
  68. ' Windows index property (read only).
  69. Public Property Get Index() As String
  70.     If TypeName(Window) <> "Nothing" Then
  71.         Index = Window.Index
  72.     Else
  73.         Index = ""
  74.     End If
  75. End Property
  76.  
  77. ' Window caption property (read/write).
  78. Public Property Let Caption(strVal As String)
  79.     Window.Caption = strVal
  80. End Property
  81.  
  82. Public Property Get Caption() As String
  83.     Caption = Window.Caption
  84. End Property
  85.  
  86. ' Window caption property (read/write).
  87. Public Property Let Visible(bVal As Boolean)
  88.     If bVal Then
  89.         frmWindow.Show
  90.     Else
  91.         frmWindow.Hide
  92.     End If
  93. End Property
  94.  
  95. Public Property Get Visible() As Boolean
  96.     Visible = frmWindow.Visible
  97. End Property
  98.  
  99. ' Window height property (read/write).
  100. Public Property Let Height(iVal As Integer)
  101.     Window.Height = iVal
  102. End Property
  103.  
  104. Public Property Get Height() As Integer
  105.     Height = Window.Height
  106. End Property
  107.  
  108. ' Window width property (read/write).
  109. Public Property Let Width(iVal As Integer)
  110.     Window.Width = iVal
  111. End Property
  112.  
  113. Public Property Get Width() As Integer
  114.     Width = Window.Width
  115. End Property
  116.  
  117. ' Window top property (read/write).
  118. Public Property Let Top(iVal As Integer)
  119.     Window.Top = iVal
  120. End Property
  121.  
  122. Public Property Get Top() As Integer
  123.     Width = Window.Top
  124. End Property
  125.  
  126. ' Window Left property (read/write).
  127. Public Property Let Left(iVal As Integer)
  128.     Window.Left = iVal
  129. End Property
  130.  
  131. Public Property Get Left() As Integer
  132.     Width = Window.Left
  133. End Property
  134.  
  135. ' Window Activate method.
  136. Public Sub Activate()
  137.     frmWindow.SetFocus
  138. End Sub
  139.  
  140. ' Window object Application property
  141. Public Property Get Application()
  142.     Set Application = modDeclares.Application
  143. End Property
  144.  
  145. ' Selected property (read/write)
  146. Public Property Get Selected() As Boolean
  147.     'Selected = mbSelected
  148. End Property
  149.  
  150. Public Property Let Selected(bVal As Boolean)
  151.     'mbSelected = bVal
  152.     If bVal = True Then
  153.         ' Add this object to the private Selection
  154.         ' collection
  155.         'modDeclares.Selection.Add Me
  156.         ' Indicate the item is selected by
  157.         ' highlighting it.
  158.        ' Me.BackColor = HIGHLIGHT
  159.     End If
  160. End Property
  161.  
  162.