Exemple #1
0
HTREEITEM CTreeViewEx::DragMoveItem(HTREEITEM hDraggingItem, HTREEITEM hDroppingItem, eTYPE_DROPPING eDropping)
{
    CTreeCtrl& omTreeCtrl = GetTreeCtrl();

    if(eDropping == NO_DROPPING)
    {
        return NULL;
    }

    if(bAnscestor(hDraggingItem, hDroppingItem) || !IsItemCanDropOn(hDraggingItem, hDroppingItem))
    {
        return NULL;
    }

    if(bSuccessor(hDraggingItem, hDroppingItem) && (eDropping == DROPPING_ABOVE))
    {
        return NULL;
    }

    if(hDraggingItem == hDroppingItem)
    {
        return NULL;
    }

    if(!hDroppingItem && eDropping == DROPPING_BELOW)
        for(hDroppingItem = omTreeCtrl.GetRootItem(); omTreeCtrl.GetNextSiblingItem(hDroppingItem) != 0; hDroppingItem = omTreeCtrl.GetNextSiblingItem(hDroppingItem));

    // Setup insertion parameters
    HTREEITEM hInsertAfter = 0;
    HTREEITEM hParent = 0;

    switch(eDropping)
    {
        case DROPPING_BELOW:
            hInsertAfter = hDroppingItem;
            hParent = omTreeCtrl.GetParentItem(hDroppingItem);
            break;

        case DROPPING_ABOVE:
            hInsertAfter = omTreeCtrl.GetPrevSiblingItem(hDroppingItem);

            if(!hInsertAfter)
            {
                hInsertAfter = TVI_FIRST;
            }

            hParent = omTreeCtrl.GetParentItem(hDroppingItem);
            break;

        default:
            ASSERT(false);
            break;
    }

    m_hDraggingItemgedItem = CopyTotalBranch(hDraggingItem, hParent, hInsertAfter);
    omTreeCtrl.DeleteItem(hDraggingItem);
    return hInsertAfter;
}
Exemple #2
0
/******************************************************************************
Function Name  :  CopyTotalBranch
Input(s)       :
Output         :  HTREEITEM
Functionality  :
Member of      :  CTreeViewEx
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  30/03/2011
Modifications  :
******************************************************************************/
HTREEITEM CTreeViewEx::CopyTotalBranch( HTREEITEM hBranchItem, HTREEITEM hNewParentItem, HTREEITEM hAfterItem /*= TVI_LAST*/ )
{
    HTREEITEM hChildItem;
    CTreeCtrl& omTreeCtrl = GetTreeCtrl();
    HTREEITEM hNewItem = CopyTreeItem( hBranchItem, hNewParentItem, hAfterItem );
    hChildItem = omTreeCtrl.GetChildItem(hBranchItem);
    while( hChildItem != NULL)
    {
        CopyTotalBranch(hChildItem, hNewItem, TVI_LAST);
        hChildItem = omTreeCtrl.GetNextSiblingItem( hChildItem );
    }
    return hNewItem;
}