home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / ToolBox_wi2097731162008.psc / cNodes.cls < prev    next >
Text File  |  2007-12-26  |  2KB  |  75 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "Nodes"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. 'local variable(s) to hold property value(s)
  17. Option Explicit
  18. DefInt A-Z
  19.  
  20. Public Caption$, Tag$, ToolTipText$
  21. 'Public Enabled As Boolean, Visible As Boolean
  22. Public Expanded As Boolean
  23. Public ClientLeft As Single, ClientHeight As Single
  24. Public ClientWidth As Single, ClientTop As Single
  25. Public Key$, Description$
  26. Public SelectedChild As Integer
  27.  
  28. Public ChildCount As Integer
  29. 'local variable(s) to hold property value(s)
  30. Private mvarChilds() As Child 'local copy
  31.  
  32. Public Property Set Childs(ByVal Index As Variant, ByVal vData As Child)
  33.   Index = KeyToIndex(Index)
  34.   Set mvarChilds(Index) = vData
  35. End Property
  36.  
  37. Public Property Get Childs(ByVal Index As Variant) As Child
  38.   Index = KeyToIndex(Index)
  39.   Set Childs = mvarChilds(Index)
  40. End Property
  41.  
  42. Private Function KeyToIndex(ByVal Index As Variant) As Integer
  43.  ' Returns the integer index value of a button identified by either it's
  44.  ' Key property or index.
  45.  Dim I
  46.  If Val(Index) = 0 Then
  47.   For I = 1 To ChildCount
  48.    If UCase$(mvarChilds(I).Key) = UCase$(Index) Then
  49.     KeyToIndex = I
  50.     Exit Function
  51.    End If
  52.   Next
  53.  Else
  54.   KeyToIndex = Val(Index)
  55.  End If
  56.  If KeyToIndex = 0 And Index <> 0 Then
  57.   Err.Raise 35601, "Nodes.KeyToIndex", "Element not found. Key is missing or illegal."
  58.  End If
  59. End Function
  60.  
  61. Public Function AddChild(cCaption As String, Optional cKey As String, Optional cIcon As StdPicture = Nothing, Optional cToolTip As String, Optional cDescription As String, Optional cMaskColor As OLE_COLOR = vbMagenta, Optional cUseMaskColor As Boolean = True) As Integer
  62.   ChildCount = ChildCount + 1
  63.   ReDim Preserve mvarChilds(ChildCount) As Child
  64.   Set mvarChilds(ChildCount) = New Child
  65.   With mvarChilds(ChildCount)
  66.     .Key = cKey
  67.     Set .Icon = cIcon
  68.     .ToolTipText = cToolTip
  69.     .MaskColor = cMaskColor
  70.     .UseMaskColor = cUseMaskColor
  71.     .Caption = cCaption
  72.   End With
  73.   AddChild = ChildCount
  74. End Function
  75.