Solved

Tree Item Selection States

Posted on 1997-02-18
1
353 Views
Last Modified: 2013-11-20
I have a tree control in one of my document views and I need to be able to enable/disable selection of items in the tree.  This means that when an item is selected and dragged to my other view, I want to still show it in the tree, but disable it from being selected and dragged again.  Any suggestions??
0
Comment
Question by:keithdd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
rob_garner earned 100 total points
ID: 1300055
In the documentation there is a state described - TVIS_DISABLED. Unfortunately this state does not really exist.

So try this...

First, after processing the initial drag set the item so that you know it has been dragged.
You could either do something like...

a.      SetItemState(hItem, TVIS_CUT, TVIS_CUT);
      This will give a visual cue that the item is not available.

      - or -

b.      Set some flag in LPARAM that you can later query
(next steps assume use of TVIS_CUT)

Next, process the TVN_BEGINDRAG notification something like this...

      UINT nFlags = GetItemState(hItem, TVIS_CUT);
      if ( nFlags & TVIS_CUT )
      {
            *pResult = 1;
            AfxMessageBox("Can't drag");
            return;
      }

This will prevent the item from being dragged, but will still allow the item to be selected.

To prevent the selection process the TVN_SELCHANGING notification something like this

void CDiskTreeCtrl::OnSelchanging(NMHDR* pNMHDR, LRESULT* pResult)
{
      NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

      HTREEITEM hItem = pNMTreeView->itemNew.hItem;
      UINT nFlags = GetItemState(hItem, TVIS_CUT);
      if ( nFlags & TVIS_CUT )
      {
            *pResult = 1;
            return;
      }
      
      *pResult = 0;
}


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 54
ORA-01403: no data found 43 112
Define unique primary key 9 95
How to determine file rename from EventLog ? 2 58
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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