G
govolsbaby
I have the following code that I got from somewhere on the web. I use
it to turn checkboxes on and off for particular nodes of a treeview.
It works fine. My problem is that I didn't write it and I don't
understand it. Obviously I'm pretty much a rank amateur here. I'm
really an aerospace engineer that sometimes writes simple software.
In my quest to learn more, could someone possible give me an English
explanation of what is going on here, especially in sub
TreeNode_SetCheckbox? Especially the hex values? Or at the very
least could you point me to the appropriate place in the documentation
so that I could investigate further on my own? I'd like to further
modify the treeview if I can, and I'm thinking that understanding what
I already have would be a good start. Thanks.
<StructLayout(LayoutKind.Sequential)> Public Structure TVITEM
Public mask As Integer
Public hItem As IntPtr
Public state As Integer
Public stateMask As Integer
<MarshalAs(UnmanagedType.LPTStr)> Public lpszText As String
Public cchTextMax As Integer
Public iImage As Integer
Public iSelectedImage As Integer
Public cChildren As Integer
Public lParam As IntPtr
End Structure
Public Overloads Declare Auto Function SendMessage Lib
"User32.dll" (ByVal _
hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr,
ByRef lParam _
As TVITEM) As Integer
Private Sub TreeNode_SetCheckBox(ByVal myNode As TreeNode, ByVal
bVisible As Boolean)
Dim iIndex As Integer = 0
If bVisible Then
iIndex = 1
End If
Dim myTVI As New TVITEM
myTVI.hItem = myNode.Handle
myTVI.mask = &H8
myTVI.stateMask = &HF000
myTVI.state = iIndex << 12
SendMessage(myNode.TreeView.Handle, &H1100 + 63, IntPtr.Zero,
myTVI)
End Sub
it to turn checkboxes on and off for particular nodes of a treeview.
It works fine. My problem is that I didn't write it and I don't
understand it. Obviously I'm pretty much a rank amateur here. I'm
really an aerospace engineer that sometimes writes simple software.
In my quest to learn more, could someone possible give me an English
explanation of what is going on here, especially in sub
TreeNode_SetCheckbox? Especially the hex values? Or at the very
least could you point me to the appropriate place in the documentation
so that I could investigate further on my own? I'd like to further
modify the treeview if I can, and I'm thinking that understanding what
I already have would be a good start. Thanks.
<StructLayout(LayoutKind.Sequential)> Public Structure TVITEM
Public mask As Integer
Public hItem As IntPtr
Public state As Integer
Public stateMask As Integer
<MarshalAs(UnmanagedType.LPTStr)> Public lpszText As String
Public cchTextMax As Integer
Public iImage As Integer
Public iSelectedImage As Integer
Public cChildren As Integer
Public lParam As IntPtr
End Structure
Public Overloads Declare Auto Function SendMessage Lib
"User32.dll" (ByVal _
hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr,
ByRef lParam _
As TVITEM) As Integer
Private Sub TreeNode_SetCheckBox(ByVal myNode As TreeNode, ByVal
bVisible As Boolean)
Dim iIndex As Integer = 0
If bVisible Then
iIndex = 1
End If
Dim myTVI As New TVITEM
myTVI.hItem = myNode.Handle
myTVI.mask = &H8
myTVI.stateMask = &HF000
myTVI.state = iIndex << 12
SendMessage(myNode.TreeView.Handle, &H1100 + 63, IntPtr.Zero,
myTVI)
End Sub