Solved

Hilighting a CTreeCtrl Item

Posted on 2004-08-24
2
617 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
2 Comments
 
LVL 19

Expert Comment

by:drichards
Comment Utility
Try setting the focus, which is what clicking the tree does:

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

Accepted Solution

by:
Zoppo earned 125 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
bigDiff challenge 17 74
lucky13 challenge 11 111
only14 challenge 19 63
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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

771 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

12 Experts available now in Live!

Get 1:1 Help Now