Microsoft KB Archive/149326

= FIX: Multiselect with ListView Causes Lost Mouse Events =

Article ID: 149326

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q149326



SYMPTOMS
When the MultiSelect property of the ListView control is set to True, neither the MouseUp or Click event is generated when the ListView control itself is clicked. The only event generated in this case is the MouseDown event. This problem occurs only if the area clicked on does not contain a ListItem object. If a ListItem is clicked, all three events are fired as expected.



RESOLUTION
The fired MouseDown event can be used instead of the Click event to execute code when a user clicks the white space of a ListView control. If it is vital that some action be taken when the mouse button is released, one can manually trap the WM_LBUTTONUP message sent to the control using a message trapping OCX or tool. The Message Blaster OCX produced by WareWithAll is a good example of a control that provides this functionality.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Basic 6.0.



Steps to Reproduce
 Start Visual Basic 4.0. Form1 is created by default. Add a single ListView control to the form. Set this property of the ListView control:

MultiSelect: True

  Add this code to Form1: Private Sub Form_Load Dim lv As ListItem Dim i As Integer

For i = 1 To 10 Set lv = ListView1.ListItems.Add(,, "Item " & i)      Next i   End Sub

Private Sub ListView1_Click Debug.Print "ListView1_Click" End Sub

Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, _    x As Single, y As Single) Debug.Print "ListView1_MouseDown" End Sub

Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, _  x As Single, y As Single) Debug.Print "ListView1_MouseUp" End Sub  Press F5 or select Start from the Run menu to run the application. Click on a portion of the ListView control that does not contain a ListItem object. Note that only the MouseDown event is fired.</ol>

Additional query words: kbVBp400bug kbVBp500fix kbVBp600fix kbVBp kbdsd kbDSupport kbControl

Keywords: kbbug kbfix KB149326

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.