Solved

Hilighting a CTreeCtrl Item

Posted on 2004-08-24
2
621 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

19 Experts available now in Live!

Get 1:1 Help Now