CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Adding icon to subitems of CListCtrl

    Hi everyone !
    How can I add an icon to the subitem in CListCtrl? I think it is possible using owner-drawn list control? But I don't know how.
    Can someone help me?

    Thanks in advance


  2. #2
    Join Date
    Apr 1999
    Location
    Norway
    Posts
    19

    Re: Adding icon to subitems of CListCtrl

    You have first to create an image list and then add it to the a CListView

    m_pImageList=new CImageList;
    m_pImageList->Create(16,16, TRUE, 2, 0);
    m_pImageList->Add(theApp.LoadIcon (IDI_LOCKICON));

    m_pImageList->Add(theApp.LoadIcon(IDI_UNLOCKICON));

    m_listFiles.SetImageList(m_pImageList, LVSIL_SMALL);


    when you after all you want to add items you have to set the style of the item like this
    item.mask = LVIF_TEXT | LVIF_IMAGE;
    and the index of the image
    item.iImage = 1;

    I hope this helps you.
    Hussam


  3. #3
    Join Date
    Apr 1999
    Location
    Bangalore, India
    Posts
    25

    Re: Adding icon to subitems of CListCtrl

    Thanks for the reply Hussam. But this will only add icons to the items (which I am able to add) and not to the subitems. If you have a way to add icons to the
    subitems, let me know.

    Vicky


  4. #4
    Join Date
    Apr 1999
    Posts
    11

    Re: Adding icon to subitems of CListCtrl

    The LV_COLUMN structure has two new fields (Version 4.7 of common controls) that allow you to specify the placement of bitmaps (from an image list) in the various columns (iImage and iOrder). Check them out. Earlier versions require complete owner-draw....



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured