Article ID: 192188
Article Last Modified on 5/12/2003
Private Sub Form_Load()
Const TVS_CHECKBOXES = &H100
Const GWL_STYLE = (-16)
Dim CurStyle As Long
Dim Result As Long
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
nodX.EnsureVisible
TreeView1.Checkboxes = True
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
' This code never gets executed
Debug.Print "NodeClick: "; TreeView1.SelectedItem.Checked
End Sub
Private Sub TreeView1_Click()
Debug.Print "Click: "; TreeView1.SelectedItem.Checked
End Sub
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Sub Form_Load()
Const TVS_CHECKBOXES = &H100
Const GWL_STYLE = (-16)
Dim CurStyle As Long
Dim Result As Long
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
nodX.EnsureVisible
TreeView1.LabelEdit = tvwManual
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
CurStyle = GetWindowLong(TreeView1.hwnd, GWL_STYLE)
Result = SetWindowLong(TreeView1.hwnd, GWL_STYLE, _
CurStyle Or TVS_CHECKBOXES)
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Debug.Print TreeView1.SelectedItem.Checked
End Sub
224181 BUG: GDI Resource Leak Using Checkboxes in ListView Control
Keywords: kbbug kbtreeview kbcmnctrls kbctrl kbpending KB192188