BUG: Adding Subitems To Hidden ListView Causes APP Error

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

SYMPTOMS

A 32-bit Visual Basic application with a ListView control can generate an application error or incorrectly display the subitems if the subitems are added to a ListView control that is hidden on a form.

STATUS

Microsoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this issue and will post new information here in the Microsoft Knowledge Base as it becomes available.

WORKAROUND

To eliminate this behavior, use one of the following methods:

If you want your ListView control in the form to be hidden when the form is shown, toggle the Visible property once before adding the subitems to the ListView control. To toggle the Visible property, initially set the Visible property to True and then reset the Visible property to False.

-or-

At design time, set the ListView control Visible property to True. Then in the first line of code in the form's Load procedure, set the ListView control Visible property to False.

MORE INFORMATION

Steps to Reproduce Issue

  1. Start the 32-bit version of Visual Basic 4.0, or if it is already running, click New Project on the File menu.

  2. Add the following controls to the Form1 form:

    - One Check Box - Two Image List Boxes - One ListView Control

  3. Set the Caption property of the Check box to "ListView Control Visible."

  4. Copy the following code to the Code window of the Form1 form:

          Private Sub Check1_Click()
    

             ListView1.Visible = Check1.Value = 1
    
          End Sub
    
          Private Sub Form_Load()
    
             'Set the ListView control's Column Headers
             Dim clmX As ColumnHeader
             Set clmX = ListView1.ColumnHeaders.Add(, , "Author", _
                        ListView1.Width / 3)
             Set clmX = ListView1.ColumnHeaders.Add(, , "Author ID", _
                        ListView1.Width / 3, lvwColumnCenter)
             Set clmX = ListView1.ColumnHeaders.Add(, , "Birthdate", _
                        ListView1.Width / 3)
    
             'Set the ListView control's view property to show a "Report" view
             ListView1.View = lvwReport
    
             'Add ListItems to the ListView control
             'Use an icon file and a bitmap file that comes with Visual Basic
              Dim imgX As ListImage
              Set imgX = ImageList1.ListImages.Add(, , LoadPicture _
                         ("C:\VB\ICONS\WRITING\NOTE06.ICO"))
              Set imgX = ImageList2.ListImages.Add(, , LoadPicture _
                         ("C:\VB\REPORT\PROLOGOB.BMP"))
              ListView1.Icons = ImageList1
              ListView1.SmallIcons = ImageList2
    
              Set itmX = ListView1.ListItems.Add(, , "John Doe")
              itmX.SubItems(1) = "John Dow Sub item"
    
          End Sub
    
    

  5. Press the F5 key to run the application.

  6. Click the check box. One of the following behaviors occur:

    While using Microsoft Windows NT version 3.51, the following error is returned:

    An application error has occurred and an application error log is being generated. VB32.exe. Exception: access violation (0xc0000005), Address: 0x0523ca55.

    While using Microsoft Windows 95, the following error is returned:

    VB32 caused an invalid page fault in module COMCTL32.OCX at 0137:0523ca55.

    -or-

    The ListView control incorrectly displays the subitems.


KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsStd
Additional reference words: 4.00 vb4win vb432 ListView errmsg buglist4.00


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 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.