CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    Netherlands
    Posts
    24

    Disable selection in CTreeCtrl

    I don't know if it is possible but I have a CTreeCtrl object with checkboxes and that works fine. The thing is that I don't like the selection in my tree. I already have checkboxes so I do not have to see what item is selected. I tried unselecting the tree item in the OnSelChanged function like this:
    Code:
    void CMyTree::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 
    {
    	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    	HTREEITEM hItem = this->GetSelectedItem();
    	this->SetItemState(hItem, 0, TVIS_SELECTED );
    
    	*pResult = 0;
    }
    But then the selecting and unselecting is noticeable. Is there a way to completely disable the selection functionality of the CTreeCtrl class?

  2. #2
    i think for this is TVN_SELCHANGING not TVN_SELCHANGED
    but works with user changes only - is this your problem?
    or this too? http://www.codeproject.com/dialog/reflectedmsgs.asp
    t!
    Last edited by real name; January 21st, 2004 at 09:21 AM.

  3. #3
    Join Date
    Jan 2004
    Location
    Netherlands
    Posts
    24
    I tried changing TVN_SELCHANED to TVN_SELCHANGING but that does not work with me. I think the problem is that MFC automatically updates the tree with a visible selection after TVN_SELCHANGING.

    The best solution would of course be to totally disable the selection ability. So that when a user clicks on the tree you do not see a blue bar and nothing (visually) changes.

    An other (dirty) solution could be to change the selection color from blue to white. But first I want to figure out if the selection can be totally disabled.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured