Solved

Change Icon in CTreeView

Posted on 1997-01-18
1
426 Views
Last Modified: 2013-11-20
How to change an icon in a CTreeView. I used the following call but the icon does not change from old one to the new.

void CJeopTreeView::ChangeItem(int nStatus)
{
      HTREEITEM hTreeItem = m_treeCtrl->GetSelectedItem();
      
      TV_ITEM TreeCtrlItem;
      
      m_treeCtrl->GetItem(&TreeCtrlItem);
      TreeCtrlItem.mask = TVIF_HANDLE      | TVIF_PARAM;
      TreeCtrlItem.hItem = hTreeItem;

      switch (nStatus)
      {
      case JEOP_RETURNED:
            TreeCtrlItem.iImage = JEOP_RETURNED;
            break;
      case JEOP_COMPLETED:
            TreeCtrlItem.iImage = JEOP_RETURNED;
            break;
      default:
            break;
      }

      BOOL b = m_treeCtrl->SetItem(&TreeCtrlItem);
}

JEOP_RETURNED is an index in the CImageList.

Could someone help out please?

Thanks!

Calvin Chi
chic@aracnet.net
0
Comment
Question by:chic
1 Comment
 

Accepted Solution

by:
amichal earned 100 total points
ID: 1300420
You need to set:

TreeCtrlItem.mask  |= TVIF_IMAGE;
before calling SetItem.

This infroms SetItemt hat the image field is valis
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question