newntui/discovermdi/src/qatree.cpp
//---------------------------------------------------------------------------------------
// This private recursive function was designed to reflect the parent status change on 
// all it's children. If you will disable the parent, all sub-tree attached to the 
// parent will be also disabled and you will be unsbale to switch sub-tree items status
// while parent is disabled. If you enable the parent status, all sub-tree will return
// to it's initial status and you will be able to switch the sub-tree items status.
//---------------------------------------------------------------------------------------
This private recursive function was designed to reflect the parent status change on
all it's children. If you will disable the parent, all sub-tree attached to the
parent will be also disabled and you will be unsbale to switch sub-tree items status
while parent is disabled. If you enable the parent status, all sub-tree will return
to it's initial status and you will be able to switch the sub-tree items status.
This private recursive function was designed to reflect the parent status change on all it ' s children . If you will disable the parent all sub - tree attached to the parent will be also disabled and you will be unsbale to switch sub - tree items status while parent is disabled . If you enable the parent status all sub - tree will return to it ' s initial status and you will be able to switch the sub - tree items status .
void CQATree::PropagateStatus(HTREEITEM node, BOOL newStatus) {
CTreeNodeInfo* info;
CString query;
CString status;
BSTR    sysQuery;
 	info=(CTreeNodeInfo *)m_Tree.GetItemData(node);
	info->m_RootEnabled=newStatus;
    query.Format("sev_get {%s} on",info->m_NodeName);
    sysQuery=query.AllocSysString();
    status=DataSourceAccessSync(&sysQuery);
    SysFreeString(sysQuery); 
	if(info->m_NodeType=="folder") {
	    if(status=="1" && newStatus==TRUE) m_Tree.SetItemImage(node,1,0);
		else                               m_Tree.SetItemImage(node,7,6);
	}
	if(info->m_NodeType=="query_0") {
	    if(status=="1" && newStatus==TRUE) m_Tree.SetItemImage(node,3,2);
		else                               m_Tree.SetItemImage(node,9,8);
	}
	if(info->m_NodeType=="query_1") {
	    if(status=="1" && newStatus==TRUE) m_Tree.SetItemImage(node,5,4);
		else                               m_Tree.SetItemImage(node,9,8);
	}
    HTREEITEM child   = m_Tree.GetChildItem(node);
	if(child!=NULL)     PropagateStatus(child,(newStatus && status=="1"));
    HTREEITEM sibling = m_Tree.GetNextSiblingItem(node);
	if(sibling!=NULL)  PropagateStatus(sibling,newStatus);
}
void CQATree :: PropagateStatus ( HTREEITEM node , BOOL newStatus ) { CTreeNodeInfo * info ; CString query ; CString status ; BSTR sysQuery ; info = ( CTreeNodeInfo * ) m_Tree . GetItemData ( node ) ; info -> m_RootEnabled = newStatus ; query . Format ( " " , info -> m_NodeName ) ; sysQuery = query . AllocSysString ( ) ; status = DataSourceAccessSync ( & sysQuery ) ; SysFreeString ( sysQuery ) ; if ( info -> m_NodeType == " " ) { if ( status == " " && newStatus == TRUE ) m_Tree . SetItemImage ( node , 1 , 0 ) ; else m_Tree . SetItemImage ( node , 7 , 6 ) ; } if ( info -> m_NodeType == " " ) { if ( status == " " && newStatus == TRUE ) m_Tree . SetItemImage ( node , 3 , 2 ) ; else m_Tree . SetItemImage ( node , 9 , 8 ) ; } if ( info -> m_NodeType == " " ) { if ( status == " " && newStatus == TRUE ) m_Tree . SetItemImage ( node , 5 , 4 ) ; else m_Tree . SetItemImage ( node , 9 , 8 ) ; } HTREEITEM child = m_Tree . GetChildItem ( node ) ; if ( child != NULL ) PropagateStatus ( child , ( newStatus && status == " " ) ) ; HTREEITEM sibling = m_Tree . GetNextSiblingItem ( node ) ; if ( sibling != NULL ) PropagateStatus ( sibling , newStatus ) ; }
This private recursive function was designed to reflect the parent status change on
all it's children.
This private recursive function was designed to reflect the parent status change on all it ' s children .
// We need a pointer to the user structure attached to the UI element. // This node will contain it's parent status. // Getting the node status // Setting the new status according to the parent status and  // the current node status.