BUG: GetItem and SetItem Do Not Have an Indent Parameter

ID: Q191128


The information in this article applies to:
  • The Microsoft Foundation Classes (MFC), included with:
    • Microsoft Visual C++, 32-bit Editions, version 6.0


SYMPTOMS

CListCtrl member functions GetItem and SetItem lack an Indent parameter.


CAUSE

The LVITEM structure was modified with version 4.70 of ComCtrl32.dll to include an indent parameter. This parameter specifies how many image widths to indent an item. However, there is no place to specify this parameter in the form of the CListCtrl member function SetItem that takes a list view item's attributes.


RESOLUTION

You can set the value of the iIndent member of the LVITEM structure by using the form of the CListCtrl member function SetItem that accepts a pointer to a LV_ITEM structure. For example:


   void CMyCListCtrl::SetItemIndent( int nItem, int nIndent )
   {
      LV_ITEM lvi;

      lvi.iItem = nItem;
      lvi.iSubItem = 0;
      lvi.mask = LVIF_INDENT;
      lvi.iIndent = nIndent;

      VERIFY( SetItem( &lvi ) );
   } 
Likewise, to obtain the indentation of an item in a CListCtrl, use the form of the CListCtrl member function GetItem that accepts a pointer to a LV_ITEM structure:

   int CMyCListCtrl::GetItemIndent( int nItem )
   {
      LV_ITEM lvi;

      lvi.iItem = nItem;
      lvi.iSubItem = 0;
      lvi.mask = LVIF_INDENT;

      VERIFY( GetItem( &lvi ) );

      return lvi.iIndent;
   } 
Note that because iIndent specifies the number of image widths to indent the item, you must associate an image list of small images with the items.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

CListCtrl::SetItem has two forms: one that takes a pointer to an LV_ITEM structure and one that takes individual parameters. The second form does not have a parameter representing the number of image widths to indent an item.

Additional query words: LVITEM LV_ITEM LVM_SETITEM LVM_GETITEM CListView

Keywords : kbcode kbnokeyword kbVC600bug kbMFC600
Version : WINNT:6.0
Platform : winnt
Issue type : kbbug


Last Reviewed: July 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.