VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3030
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3030
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSComctlLib.TreeView TreeView1
Height = 2535
Left = 120
TabIndex = 0
Top = 240
Width = 4335
_ExtentX = 7646
_ExtentY = 4471
_Version = 393217
Style = 7
Appearance = 1
End
Begin VB.Menu mnuPopup
Caption = "Popup"
Visible = 0 'False
Begin VB.Menu mnuOpen
Caption = "Open"
End
Begin VB.Menu mnuDelete
Caption = "Delete"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim i As Long
TreeView1.Nodes.Add , , "Root", "Root"
For i = 1 To 100
TreeView1.Nodes.Add "Root", tvwChild, , "Node " & i
Next i
TreeView1.Nodes("Root").Expanded = True
End Sub
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim NodeX As Node
If Button = 2 Then
Set NodeX = TreeView1.HitTest(x, y)
If Not NodeX Is Nothing Then
TreeView1.SelectedItem.Selected = False
NodeX.BackColor = vbHighlight
NodeX.ForeColor = vbHighlightText
Form1.PopupMenu mnuPopup
TreeView1.SelectedItem.Selected = True
NodeX.BackColor = vbWindowBackground
NodeX.ForeColor = vbWindowText
End If
End If
End Sub
~ Y Y Y Y Y Y
~ Y YYY Y Y Y YYYY
~ Y Y YYYY Y Y Y YYYYY
~ YYYYYYYYYYYYYY Y Y Y Y Y Y
~ Y Y Y Y Y Y Y Y YY YYYYYYYY Y Y
~ Y Y Y YYYYYY Y Y YY Y Y Y Y Y Y Y
~ Y Y Y Y Y Y Y Y Y Y Y Y Y Y
~ Y Y Y YY Y Y Y Y Y Y YYYYYYYYYYYYYY
~ YYYYYYYYYYYYY YYY Y Y Y Y Y
~ Y Y Y Y Y Y Y Y YYYYYYYYYYYY Y
~ Y Y Y Y Y Y Y Y Y Y
~ Y Y Y Y Y Y Y Y Y Y Y
~ Y Y Y Y Y Y Y Y Y Y
~ Y Y Y YYY Y Y Y Y Y YY
~ Y Y Y Y Y Y YYY Y Y Y Y
~ Y YY YY Y Y