Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - How to deselect items in tree control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to deselect items in tree control

 Post Reply Post Reply
Author
Message
Norbini View Drop Down
Newbie
Newbie


Joined: 23 January 2014
Location: Cambridge, UK
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Norbini Quote  Post ReplyReply Direct Link To This Post Topic: How to deselect items in tree control
    Posted: 30 January 2014 at 11:39am
Hi,

  I've seen that I can select items in a multi-select tree control using SelectItem() or SelectItems(), but what is the correct way to deselect items?

  I guess it is possible to do (in pseudocode):
    CTypedPtrList<CPtrList, HTREEITEM> CurrentSelection;
    GetSelectedItems(CurrentSelection);   // Get the list of currently selected items
    SelectAll(FALSE, NULL); // Deselect all items
    for (PreviouslySelectedItem in CurrentSelection) {
        if (PreviouslySelectedItem != ItemToDeselect) {
            SelectItem(PreviouslySelectedItem); // Select all previously selected items except the item to deselect
        }
    }

  However, I suspect this will generate a large number of TVN_SELCHANGED messages and probably make the selection flicker.

  Is there a better way that I'm missing or would this approach be ok?

  Many thanks in advance,
    -Nige
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.