Solved

Change Icon in CTreeView

Posted on 1997-01-18
1
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 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