home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / tidict_1 / tidict~1.exe / Viewer / DictTreeView.ctl < prev    next >
Encoding:
Text File  |  1998-06-18  |  3.8 KB  |  127 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Begin VB.UserControl DictTreeView 
  4.    ClientHeight    =   3600
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4800
  8.    ScaleHeight     =   3600
  9.    ScaleWidth      =   4800
  10.    Begin ComctlLib.TreeView TV 
  11.       Height          =   3015
  12.       Left            =   0
  13.       TabIndex        =   0
  14.       Top             =   0
  15.       Width           =   2145
  16.       _ExtentX        =   3784
  17.       _ExtentY        =   5318
  18.       _Version        =   327682
  19.       HideSelection   =   0   'False
  20.       Indentation     =   529
  21.       LabelEdit       =   1
  22.       PathSeparator   =   "."
  23.       Sorted          =   -1  'True
  24.       Style           =   7
  25.       ImageList       =   "ImageList3"
  26.       Appearance      =   1
  27.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  28.          Name            =   "MS Sans Serif"
  29.          Size            =   8.25
  30.          Charset         =   204
  31.          Weight          =   400
  32.          Underline       =   0   'False
  33.          Italic          =   0   'False
  34.          Strikethrough   =   0   'False
  35.       EndProperty
  36.    End
  37.    Begin ComctlLib.ImageList ImageList3 
  38.       Left            =   4080
  39.       Top             =   2820
  40.       _ExtentX        =   1005
  41.       _ExtentY        =   1005
  42.       BackColor       =   -2147483643
  43.       ImageWidth      =   16
  44.       ImageHeight     =   16
  45.       MaskColor       =   16777215
  46.       _Version        =   327682
  47.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  48.          NumListImages   =   4
  49.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  50.             Picture         =   "DictTreeView.ctx":0000
  51.             Key             =   ""
  52.          EndProperty
  53.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  54.             Picture         =   "DictTreeView.ctx":031A
  55.             Key             =   ""
  56.          EndProperty
  57.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  58.             Picture         =   "DictTreeView.ctx":0634
  59.             Key             =   ""
  60.          EndProperty
  61.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  62.             Picture         =   "DictTreeView.ctx":072E
  63.             Key             =   ""
  64.          EndProperty
  65.       EndProperty
  66.    End
  67. End
  68. Attribute VB_Name = "DictTreeView"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = True
  71. Attribute VB_PredeclaredId = False
  72. Attribute VB_Exposed = False
  73. Option Explicit
  74.  
  75. Const iiGroup = 1
  76. Const iiGroupSelected = 1
  77. Const iiGroupExpanded = 2
  78.  
  79. Dim mPath As String
  80.  
  81. Public Event PathChanged(ByVal Path As String)
  82.  
  83. Private Sub LoadLevel(Node As Node)
  84.   Dim I As TIDICTIONARYLib.Item, N As Node
  85.   For Each I In Dict
  86.     If I.IsDictionary Then
  87.       Set N = TV.Nodes.Add(Node, tvwChild, "@." & I.Path, I.Name, iiGroup, iiGroupSelected)
  88.       I.Open
  89.         LoadLevel N
  90.       Dict.Close
  91.     End If
  92.   Next
  93. End Sub
  94.  
  95. Public Sub RefreshView()
  96.   Dim R As Node
  97.   TV.Nodes.Clear:   Set R = TV.Nodes.Add(, , "@", "@", iiGroup, iiGroupSelected)
  98.   Dict.GoRoot
  99.   LoadLevel R
  100.   R.Expanded = True
  101. End Sub
  102.  
  103. Private Sub TV_NodeClick(ByVal Node As ComctlLib.Node)
  104.   RaiseEvent PathChanged(Node.FullPath)
  105. End Sub
  106.  
  107. Private Sub UserControl_Resize()
  108.   On Error Resume Next
  109.   TV.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
  110. End Sub
  111.  
  112. Public Property Get Path() As String
  113.   Path = mPath
  114. End Property
  115.  
  116. Public Sub SelectItem(ByVal Path As String, ByVal ItemName As String)
  117.   Dim Node As Node
  118.   If ItemName = ".." Then
  119.     Set Node = TV.Nodes.Item(Path).Parent
  120.   Else
  121.     Set Node = TV.Nodes.Item(Path & "." & ItemName)
  122.   End If
  123.   Node.EnsureVisible
  124.   Node.Selected = True
  125.   mPath = Node.FullPath
  126. End Sub
  127.