Solved

Hilighting a CTreeCtrl Item

Posted on 2004-08-24
2
634 Views
Last Modified: 2013-11-20
I have a CTreeCtrl. There is an interface to reorder the items in the list. The reordering works fine. I find the selected item, get its data, remove it and reinsert it at the correct spot. After I reinsert the item, I want to select the item that was moved.

I tried:
      m_rasterList.SelectItem(item);
      m_rasterList.SetItemState(item, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
but this doesn't highlight the selected item until you click on the tree again. I also tried calling invalidate but that didn't redraw the tree correctly either.

I also tried
      m_rasterList.SelectItem(item);
      m_rasterList.SetDropTarget(item);
This works till I select another item, then old item stays highlighted but the new one becomes selected.

-Tom
0
Comment
Question by:tcf22
[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
2 Comments
 
LVL 19

Expert Comment

by:drichards
ID: 11888250
Try setting the focus, which is what clicking the tree does:

    m_rasterList.SelectItem(item);
    m_rasterList.SetFocus();
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 125 total points
ID: 11901469
Hi tcf22,

you can even try to assign the style TVS_SHOWSELALWAYS  to the tree control ... this causes the tree control to show selected item
as selected even if it doesn't have the focus.

hope that helps,

ZOPPO
0

Featured Post

Industry Leaders: 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

696 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