Solved

Change Icon in CTreeView

Posted on 1997-01-18
1
423 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
configuration management 2 100
format the code in java 6 72
has22 challenge 11 72
fizzArray  challenge 1 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now