home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / protview / demowinx / data.1 / UDLRFRM.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-29  |  8.0 KB  |  260 lines

  1. VERSION 4.00
  2. Begin VB.Form UDLRFrm
  3.    Caption         =   "TreeView"
  4.    ClientHeight    =   5760
  5.    ClientLeft      =   2070
  6.    ClientTop       =   1395
  7.    ClientWidth     =   6990
  8.    Height          =   6165
  9.    Left            =   2010
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5760
  12.    ScaleWidth      =   6990
  13.    Top             =   1050
  14.    Width           =   7110
  15.    Begin PVButtonLib.PVButton Command1
  16.       Height          =   495
  17.       Left            =   0
  18.       TabIndex        =   8
  19.       Top             =   840
  20.       Width           =   495
  21.       _Version        =   65541
  22.       _ExtentX        =   873
  23.       _ExtentY        =   873
  24.       _StockProps     =   70
  25.       Picture         =   5
  26.       Caption         =   ""
  27.       CustomPicture   =   "UDLRFrm.frx":0000
  28.    End
  29.    Begin VB.Label Label6
  30.       Caption         =   "Click the '+' button to insert a new top level node"
  31.       Height          =   255
  32.       Left            =   600
  33.       TabIndex        =   7
  34.       Top             =   1320
  35.       Width           =   6135
  36.    End
  37.    Begin VB.Label Label5
  38.       Caption         =   "Double-click an item or hit the Return key to change its text"
  39.       Height          =   255
  40.       Left            =   600
  41.       TabIndex        =   6
  42.       Top             =   1080
  43.       Width           =   6135
  44.    End
  45.    Begin VB.Label Label4
  46.       Caption         =   "Use the Right arrow or Insert key to insert a new item as the child of the current item"
  47.       Height          =   255
  48.       Left            =   600
  49.       TabIndex        =   5
  50.       Top             =   840
  51.       Width           =   6135
  52.    End
  53.    Begin VB.Label Label3
  54.       Caption         =   "Use the Left arrow or Delete key to delete the current item and all its chilldren"
  55.       Height          =   255
  56.       Left            =   600
  57.       TabIndex        =   4
  58.       Top             =   600
  59.       Width           =   6135
  60.    End
  61.    Begin VB.Label Label2
  62.       Caption         =   "Use the Down arrow to change selection to the next item"
  63.       Height          =   255
  64.       Left            =   600
  65.       TabIndex        =   3
  66.       Top             =   360
  67.       Width           =   6135
  68.    End
  69.    Begin VB.Label Label1
  70.       Caption         =   "Use the Up arrow to change selection to the previous item."
  71.       Height          =   255
  72.       Left            =   600
  73.       TabIndex        =   2
  74.       Top             =   120
  75.       Width           =   6135
  76.    End
  77.    Begin PVTreeViewLib.PVTreeView PTreeView1
  78.       Height          =   3780
  79.       Left            =   120
  80.       TabIndex        =   1
  81.       Top             =   1800
  82.       Width           =   6015
  83.       _Version        =   65541
  84.       _ExtentX        =   10610
  85.       _ExtentY        =   6668
  86.       _StockProps     =   228
  87.       Appearance      =   1
  88.       Sort            =   0   'False
  89.       AlwaysShowSelection=   -1  'True
  90.    End
  91.    Begin PVMultiBtnLib.PVMultiBtn Multibtn1
  92.       Height          =   435
  93.       Left            =   0
  94.       TabIndex        =   0
  95.       Top             =   120
  96.       Width           =   435
  97.       _Version        =   65541
  98.       _ExtentX        =   767
  99.       _ExtentY        =   767
  100.       _StockProps     =   224
  101.    End
  102. Attribute VB_Name = "UDLRFrm"
  103. Attribute VB_Creatable = False
  104. Attribute VB_Exposed = False
  105. Private Sub Command1_Click()
  106. Set root = PTreeView1.Branches
  107. Set NewNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  108. NewNode.Select pvtNode
  109. Dim ret As String
  110. ret = InputBox("Enter text for item", "Caption", NewNode.Text)
  111. If (ret <> "") Then
  112.    NewNode.Text = ret
  113. End If
  114. End Sub
  115. Private Sub Form_Load()
  116. Dim root As Branch
  117. Dim ParentNode As Branch
  118. Dim ChildNode As Branch
  119. PTreeView1.AutoOpen = True
  120. PTreeView1.EnableLines = True
  121. PTreeView1.EnableMicroBitmaps = True
  122. PTreeView1.EnableBitmaps = True
  123. Set root = PTreeView1.Branches
  124. Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  125. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  126. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  127. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  128. ParentNode.Select 1
  129. Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  130. Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node")
  131. End Sub
  132. Private Sub Multibtn1_Down()
  133. Dim root As Branch
  134. Dim node As Branch
  135. Dim NextNode As Branch
  136. Set root = PTreeView1.Branches
  137. Set node = root.Get(pvtGetChild, 0)
  138. If (node.IsValid) Then
  139.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  140.    If (NextNode.IsValid = True) Then
  141.       Rem get the next item in the tree
  142.       Set node = NextNode.Get(pvtGetNextVisible, 0)
  143.       If (node.IsValid = True) Then
  144.          node.Select pvtNode
  145.       Else
  146.          Rem we are at the last item in the tree
  147.       End If
  148.    Else
  149.       Rem select the first item in the tree
  150.       node.Select pvtNode
  151.    End If
  152.    Rem no items in tree, do nothing
  153. End If
  154. End Sub
  155. Private Sub Multibtn1_Left()
  156. Dim root As Branch
  157. Dim node As Branch
  158. Dim NextNode As Branch
  159. Set root = PTreeView1.Branches
  160. Set node = root.Get(pvtGetChild, 0)
  161. If (node.IsValid) Then
  162.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  163.    If (NextNode.IsValid) Then
  164.       NextNode.Remove
  165.    End If
  166. End If
  167. End Sub
  168. Private Sub Multibtn1_Right()
  169. Dim root As Branch
  170. Dim node As Branch
  171. Dim NextNode As Branch
  172. Dim NewNode As Branch
  173. Set root = PTreeView1.Branches
  174. Set node = root.Get(pvtGetChild, 0)
  175. If (node.IsValid) Then
  176.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  177.    If (NextNode.IsValid) Then
  178.       Set NewNode = NextNode.Add(pvtPositionInOrder, 0, "New Node")
  179.       NewNode.Select pvtNode
  180.    Else
  181.       Set NewNode = node.Add(pvtPositionInOrder, 0, "Child Node")
  182.       NewNode.Select pvtNode
  183.    End If
  184.    Set NewNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  185.    NewNode.Select pvtNode
  186. End If
  187. Dim ret As String
  188. ret = InputBox("Enter text for item", "Caption", NewNode.Text)
  189. If (ret <> "") Then
  190.    NewNode.Text = ret
  191. End If
  192. End Sub
  193. Private Sub Multibtn1_Up()
  194. Dim root As Branch
  195. Dim node As Branch
  196. Dim NextNode As Branch
  197. Set root = PTreeView1.Branches
  198. Set node = root.Get(pvtGetChild, 0)
  199. If (node.IsValid) Then
  200.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  201.    If (NextNode.IsValid) Then
  202.       Rem get the previous item in the tree
  203.       Set node = NextNode.Get(pvtGetPrevVisible, 0)
  204.       If (node.IsValid = True) Then
  205.          node.Select pvtNode
  206.       Else
  207.          Rem we are at the first item in the tree
  208.       End If
  209.    Else
  210.       Rem select the first item in the tree
  211.       node.Select pvtNode
  212.    End If
  213.    Rem no items in tree, do nothing
  214. End If
  215. End Sub
  216. Private Sub PTreeView1_KeyDown(KeyCode As Integer, Shift As Integer)
  217. If (KeyCode = vbKeyLeft Or KeyCode = vbKeyDelete) Then
  218.    Multibtn1_Left
  219. End If
  220. If (KeyCode = vbKeyRight Or KeyCode = vbKeyInsert) Then
  221.    Multibtn1_Right
  222. End If
  223. If (KeyCode = vbKeyReturn) Then
  224.    Set root = PTreeView1.Branches
  225.     Set node = root.Get(pvtGetChild, 0)
  226.    If (node.IsValid) Then
  227.       Set NextNode = node.Get(pvtGetNextSelected, 0)
  228.       If (NextNode.IsValid) Then
  229.          PTreeView1.BeginInPlaceEdit
  230. '         ret = InputBox("Enter text for item", "Caption", NextNode.Text)
  231. '         If (ret <> "") Then
  232. '            NextNode.Text = ret
  233. '         End If
  234.       End If
  235.    End If
  236. End If
  237. End Sub
  238. Private Sub PTreeView1_LButtonDblClick(ByVal node As Branch, ByVal x As Single, ByVal y As Single)
  239. Dim ret As String
  240. If (node Is Nothing = False) Then
  241.     PTreeView1.BeginInPlaceEdit
  242. '   ret = InputBox("Enter text for item", "Caption", node.Text)
  243. '   If (ret <> "") Then
  244. '      node.Text = ret
  245. '   End If
  246. End If
  247. End Sub
  248. Private Sub Select_Click()
  249. If (SelectBox.Value) Then
  250. PTreeView1.SelectMode = 2
  251. PTreeView1.SelectMode = 0
  252. End If
  253. End Sub
  254. Private Sub SelectBox_Click()
  255. If (SelectBox.Value = 1) Then
  256.    PTreeView1.SelectMode = 2
  257.    PTreeView1.SelectMode = 0
  258. End If
  259. End Sub
  260.