コード例 #1
0
void CTreeViewEx::vSetCheckParent(HTREEITEM hItem)
{
    if(hItem == NULL)
    {
        return;
    }
	CTreeCtrl &omTreeCtrl = GetTreeCtrl();
	HTREEITEM hParentItem = omTreeCtrl.GetParentItem(hItem);
    HTREEITEM hChildItem;
    BOOL bAllChecked = TRUE;
    if( omTreeCtrl.ItemHasChildren(hParentItem))
    {
        hChildItem = omTreeCtrl.GetChildItem(hParentItem);
        while(hChildItem)
        {   
            if(!bIsItemChecked(hChildItem))
            {
                bAllChecked = FALSE;
                break;
            }
            hChildItem = omTreeCtrl.GetNextSiblingItem(hChildItem);
        }
    }
    vSetCheck(hParentItem, bAllChecked);
    vSetCheckParent(hParentItem);
	return;
}
コード例 #2
0
void CTreeViewEx::vSetCheckChildren(HTREEITEM hItem, BOOL fCheck)
{
    if(hItem == NULL)
    {
        return;
    }
    CTreeCtrl &omTreeCtrl = GetTreeCtrl();
	
    HTREEITEM hNext = omTreeCtrl.GetChildItem(hItem);
    
    vSetCheck(hItem, fCheck);
	
    // loop to set item state for children
	if ( omTreeCtrl.ItemHasChildren(hItem))
    {
        HTREEITEM htiChild = omTreeCtrl.GetChildItem (hItem);
        if (htiChild == NULL)
        {
            return;
        }
        else
        {
            vSetCheckChildren(htiChild, fCheck);
        }
        HTREEITEM htiSibling = omTreeCtrl.GetNextSiblingItem (htiChild);
        while (htiSibling )
        {
            vSetCheckChildren(htiSibling, fCheck);
            htiSibling = omTreeCtrl.GetNextSiblingItem(htiSibling);
        }
    }

	return;
}
コード例 #3
0
void CCheckBoxTree::vSetCheckParent(HTREEITEM hItem)
{
    if(hItem == nullptr)
    {
        return;
    }

    HTREEITEM hParentItem = GetParentItem(hItem);
    HTREEITEM hChildItem;
    BOOL bAllChecked = TRUE;
    if( ItemHasChildren(hParentItem))
    {
        hChildItem = GetChildItem(hParentItem);
        while(hChildItem)
        {
            if(!bIsItemChecked(hChildItem))
            {
                bAllChecked = FALSE;
                break;
            }
            hChildItem = GetNextSiblingItem(hChildItem);
        }
    }
    BOOL fCheck=0;
    vSetCheck(hParentItem, bAllChecked);
    vSetCheckParent(hParentItem);
    vSetCheckChildren(hParentItem,!fCheck);
}
コード例 #4
0
void CCheckBoxTree::vSetCheckChildren(HTREEITEM hItem, BOOL fCheck)
{
    if(hItem == nullptr)
    {
        return;
    }

    vSetCheck(hItem, fCheck);

    // loop to set item state for children
    if ( ItemHasChildren(hItem))
    {
        HTREEITEM htiChild = GetChildItem (hItem);
        while (htiChild != nullptr)
        {
            vSetCheck(htiChild, fCheck);
            vSetCheckChildren(htiChild, fCheck);
            htiChild = GetNextSiblingItem(htiChild);
        }
    }
}
コード例 #5
0
ファイル: TreeViewEx.cpp プロジェクト: Mariale13/UDS_Protocol
void CTreeViewEx::OnLButtonDown(UINT nFlags, CPoint point)
{
    UINT nHitTestFlags = 0;
    HTREEITEM hItem = GetTreeCtrl().HitTest(point, &nHitTestFlags);

    if((hItem != NULL) && (TVHT_ONITEMSTATEICON & nHitTestFlags))
    {
        BOOL bCheck = bIsItemChecked(hItem);
        vSetCheck(hItem, !bCheck);
        return;
    }
    CTreeView::OnLButtonDown(nFlags, point);
}
コード例 #6
0
/******************************************************************************
Function Name  :  OnLButtonDown
Input(s)       :  UINT unFlag - Flags
                  CPoint point - Mouse Pointer point
Output         :  void
Functionality  :  ON_WM_LBUTTON Handler used to toggle the check point
Member of      :  CTreeViewEx
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  30/03/2011
Modifications  :
******************************************************************************/
void CTreeViewEx::OnLButtonDown(UINT unFlag, CPoint point)
{
    UINT unHitTestFlags = 0;
    HTREEITEM hItem = GetTreeCtrl().HitTest(point, &unHitTestFlags);

    if((hItem != nullptr) && (TVHT_ONITEMSTATEICON & unHitTestFlags))
    {
        BOOL bCheck = bIsItemChecked(hItem);
        vSetCheck(hItem, !bCheck);
        vSetCheckChildren(hItem, !bCheck);
        vSetCheckParent(hItem);
        return;
    }
    CTreeView::OnLButtonDown(unFlag, point);
}