Solved

Hilighting a CTreeCtrl Item

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

831 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