BUG: Multiselect with ListView Causes Lost Mouse Events

Last reviewed: October 3, 1996
Article ID: Q149326
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 32-bit only, for Windows, version 4.0

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.

WORKAROUND

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 an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce

  1. Start Visual Basic 4.0. Form1 is created by default.

  2. Add a single ListView control to the form.

  3. Set this property of the ListView control:

       MultiSelect:   True
    
    

  4. 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
    
    

  5. 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.


Additional reference words: 4.00 vb4win vb432
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsCus



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 3, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.