Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTTreeCtrl mutli selection problems
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTTreeCtrl mutli selection problems

 Post Reply Post Reply
Author
Message
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Topic: CXTTreeCtrl mutli selection problems
    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

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).




Back to Top
Alex View Drop Down
Groupie
Groupie
Avatar

Joined: 12 May 2004
Status: Offline
Points: 54
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2008 at 5:26pm
Hi,
 
could you solve this problem ?
 
I have the same problem...
 
Regards.
Alex
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Alex View Drop Down
Groupie
Groupie
Avatar

Joined: 12 May 2004
Status: Offline
Points: 54
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2008 at 5:27am
Thank you.
 
I have found a similar solution.
 
Regards,
Alex
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.047 seconds.