Print Page | Close Window

CXTTreeCtrl mutli selection problems

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=7826
Printed Date: 14 November 2025 at 10:12am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTTreeCtrl mutli selection problems
Posted By: scottp
Subject: CXTTreeCtrl mutli selection problems
Date Posted: 17 August 2007 at 10:24am
We are using the CXTTreeCtrl in multi-select mode and have found that tracking the items being selected and deselected using the TVN_SELCHANGED message does not work when selecting multiple items using CTRL and SHIFT. The visual appearance of the trees selection is correct but it is impossible to track the changes.

I have attached a modified TreeCtrl sample that helps show the problem (use the multiselect tree) - message boxes will popup to show which items are being selected and deselected.

uploads/20070817_102009_TreeCtrl_Sample.zip - uploads/20070817_102009_TreeCtrl_Sample.zip

Test scenario 1:
  1. Select item 1
    1. notified that item 1 is selected
  2. CTRL select item 2
    1. notified that item 1 is deselected
    2. notified that item 2 is selected
Test scenario 2:
  1. Select item 1
    1. notified that item 1 is selected
  2. SHIFT select item 3
    1. notified that item 1 is deselected
    2. notified that item 2,3 are selected
Both Vista and XP show similar behaviour (although on Vista the tree seems to send more TVN_SELCHANGED notifications).







Replies:
Posted By: Alex
Date Posted: 11 January 2008 at 5:26pm
Hi,
 
could you solve this problem ?
 
I have the same problem...
 
Regards.
Alex


Posted By: scottp
Date Posted: 15 January 2008 at 9:01pm
Hi,

I did find a way to get around this by filtering out focus changes in OnSelectionChange.

BOOL CMyTreeCtrl::OnSelectionChange (NMHDR* pNMHDR, LRESULT* pResult)
  {
  NMTREEVIEW* pTv;
  pTv = (NMTREEVIEW*)pNMHDR;
  *pResult = 0;

  HTREEITEM hFocusedItem = GetFocusedItem ();
  HTREEITEM hNewItem = pTv->itemNew.hItem;
  HTREEITEM hOldItem = pTv->itemOld.hItem;
  if ( !hFocusedItem && hOldItem && !hNewItem )
    {
    // then me must have a Focus change and we don't want to process this as a selection change.
    }
  else
    {
    if (hNewItem)
      {
       CMyTreeItem* pData = GetMyTreeItem (hNewItem);
       //select item
      }
    if (hOldItem)
      {
      CMyTreeItem* pData = GetMyTreeItem (hOldItem);
      // deselect item
      }
    }

Hope this helps



Posted By: Alex
Date Posted: 16 January 2008 at 5:27am
Thank you.
 
I have found a similar solution.
 
Regards,
Alex



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net