您的位置:首页 > Web前端 > Node.js

BUG:TreeView: NodeCheck Event Does Not Occur

2009-12-28 09:30 537 查看

BUG: TreeView: NodeCheck Event Does Not Occur

View products that this article applies to.if (!loadTOCNode) {var loadTOCNode = function(){}}
This article was previously published under Q221557


On This Page



SYMPTOMS




RESOLUTION



Step by Step Example




STATUS




MORE INFORMATION



Steps to Reproduce Behavior




REFERENCES


var sectionFilter = "type != 'notice' && type != 'securedata' && type != 'querywords'";
var tocArrow = "/library/images/support/kbgraphics/public/en-us/downarrow.gif";
var depthLimit = 10;
var depth3Limit = 10;
var depth4Limit = 5;
var depth5Limit = 3;
var tocEntryMinimum = 1;
#tocTitle, #tocDiv{display: none;}
Expand all | Collapse all
if (kb_page_object)
{
kb_page_object.kb_imageExpandHoverText = 'Click to expand this image';
}


SYMPTOMS
When a TreeView control with the Checkboxes property set to True is placed on a...

loadTOCNode(1, 'symptoms');

When a TreeView control with the Checkboxes property set to True is placed on a form and the user presses the left-mouse button over a checkbox and then drags the mouse away from the checkbox before releasing the mouse button, the state of the checkbox is toggled, but a NodeCheck event does not occur.


Back to the top


RESOLUTION
You can work around the problem by programmatically ensuring that the event occu...

loadTOCNode(1, 'resolution');

You can work around the problem by programmatically ensuring that the event occurs if the mouse has been dragged away from the checkbox.


Back to the top

Step by Step Example

loadTOCNode(2, 'resolution');

Open a new Visual Basic Standard Exe project. Form1 is created by default.
On the Project menu, click Components. Select Microsoft Common Controls 6.0 and click OK.
Add a TreeView control to Form1.
Add the following code to the General Declarations section of Form1:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long   ' <---

' treeview messages
Private Const TV_FIRST = &H1100
' wParam = 0, lParam = lptvhti, rtns hItem
Private Const TVM_HITTEST = (TV_FIRST + 17)

Private Type POINTAPI   ' pt
x As Long
y As Long
End Type

' structure passed with the TVM_HITTEST message
Private Type TVHITTESTINFO
pt As POINTAPI
flags As Long
hItem As Long
End Type

' TVHITTESTINFO.flags value. An item's checkbox
' is in fact held in the item's state icon image.
Private Const TVHT_ONITEMSTATEICON = &H40

Private m_nodChecked As Node

Private Sub Form_Load()
Dim Node1 As Node
Dim Node2 As Node
Dim Node3 As Node
Dim i As Integer
Dim j As Integer
Dim k As Integer
' For some convenience...
With TreeView1
.HideSelection = False
.Indentation = 19 * Screen.TwipsPerPixelX
.LabelEdit = tvwManual
.LineStyle = tvwRootLines
.Checkboxes = True
End With

' Fill up the treeview...
For i = 1 To 2
Set Node1 = TreeView1.Nodes.Add(, , , "Root" & i)
For j = 1 To 3
Set Node2 = TreeView1.Nodes.Add(Node1.Index, tvwChild, , _
"Root" & i & "Child" & j)
For k = 1 To 3
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, , _
"GrandChild" & (16 * (i - 1)) + (4 * (j - 1)) + k)
Next k
Next j
Node1.Expanded = True
Next i
End Sub

Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, _
x As Single, y As Single)
Dim tvhti As TVHITTESTINFO

Debug.Print "MouseDown: " & Button & " " & Shift & "  " & _
x & " " & y

If (Button = vbLeftButton) Then
' determine if the mouse pointer is being depressed over the Node's
' checkbox (assumes that the Form's ScaleMode is set to vbTwips).
tvhti.pt.x = x / Screen.TwipsPerPixelX
tvhti.pt.y = y / Screen.TwipsPerPixelY
If (SendMessage(TreeView1.hWnd, TVM_HITTEST, 0, tvhti)) Then

If (tvhti.flags And TVHT_ONITEMSTATEICON) Then
' the value of the Node's Checked property will be toggled
' *after* this procedure finishes execution.
Set m_nodChecked = TreeView1.HitTest(x, y)
End If

End If   ' TVM_HITTEST
End If   ' (Button = vbLeftButton)
End Sub

Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)

If (Node Is m_nodChecked) Then

' Either the left-mouse button is being released over the Node
' whose checkbox has been toggled, or this event procedure
' is being called from TreeView1_MouseUp. This *is* where we
' want to process code...
Debug.Print "NodeCheck: " & m_nodChecked & _
".Checked = " & m_nodChecked.Checked & _
vbCrLf & vbTab & " (do process code here)"

' De-reference the module level Node variable so you don't
' call this event again in TreeView1_MouseUp.
Set m_nodChecked = Nothing

Else
' This event is being raised by the TreeView because the mouse
' pointer is being released over a node whose checkbox state
' has *not* been toggled. you do *not* want to process code here...
Debug.Print "NodeCheck: " & Node & _
".Checked = " & Node.Checked & _
vbCrLf & vbTab & " (do *not* process code here)"

End If
End Sub

Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, _
x As Single, y As Single)

If (m_nodChecked Is Nothing) = False Then

' You didn't get a NodeCheck event (the variable is still set),
' the mouse pointer is *not* over the Node whose checkbox
' state has been toggled. Explicitly call the event procedure.
Call TreeView1_NodeCheck(m_nodChecked)

End If

Debug.Print "MouseUp: " & Button & " " & Shift & " " & _
x & " " & y
End Sub

Run the program and position the mouse cursor over a checkbox. Press and hold down the left-mouse button, drag the mouse cursor away from the checkbox, and then release the mouse button. Note that a message verifying that the NodeCheck event occurred is printed in the Immediate pane.



Back to the top


STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are li...

loadTOCNode(1, 'status');

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.


Back to the top


MORE INFORMATION
Steps to Reproduce Behavior Open a new Visual Basic Standard Exe project. Form1...

loadTOCNode(1, 'moreinformation');

Steps to Reproduce Behavior

loadTOCNode(2, 'moreinformation');

Open a new Visual Basic Standard Exe project. Form1 is created by default.
On the Project menu, click Components. Select Microsoft Common Controls 6.0 and click OK.
Add a Treeview control to Form1. Open the Treeview control's property page by right-clicking on the control and clicking Properties. Check the Treeview control's Checkboxes property and click OK.
Add the following code to the General Declarations section of Form1:

Private Sub Form_Load()
Dim Node1 As Node
Dim Node2 As Node
Dim Node3 As Node
Dim i As Integer
Dim j As Integer
Dim k As Integer

' For some convenience...
With TreeView1
.HideSelection = False
.Indentation = 19 * Screen.TwipsPerPixelX
.LabelEdit = tvwManual
.LineStyle = tvwRootLines
End With

' Fill up the treeview...
For i = 1 To 2
Set Node1 = TreeView1.Nodes.Add(, , , "Root" & i)
For j = 1 To 3
Set Node2 = TreeView1.Nodes.Add(Node1.Index, tvwChild, , _
"Root" & i & "Child" & j)
For k = 1 To 3
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, , _
"GrandChild" & (16 * (i - 1)) + (4 * (j - 1)) + k)
Next k
Next j
Node1.Expanded = True
Next i
End Sub

Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
Debug.Print "NodeCheck Event"
End Sub

Run the program. Position the mouse cursor over a checkbox, press and release the left-mouse button on the checkbox, and note that the message is printed in the Immediate pane.
Position the mouse cursor over a checkbox, and press and hold down the left-mouse button. Drag the mouse cursor away from the checkbox and then release the mouse button. Note that no message appears.



Back to the top

http://support.microsoft.com/kb/221557/en-us/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐