newntui/discovermdi/src/qatree.cpp
//---------------------------------------------------------------------------------------
// This callback runs every time the user clicked the mouse left button inside the tree
// control (CTreeControl sends us nofification message in the form WM_NOTIFY). We will
// use this event to change node status, if the click was done inside the status box.
// The node status can be changed if this node has no parent with the status set to off,
// this mean that turning off folder state will turn off all it's elements and it will
// be impossible to switch the status of the elements while the folder is off.
//---------------------------------------------------------------------------------------
This callback runs every time the user clicked the mouse left button inside the tree
control (CTreeControl sends us nofification message in the form WM_NOTIFY). We will
use this event to change node status, if the click was done inside the status box.
The node status can be changed if this node has no parent with the status set to off,
this mean that turning off folder state will turn off all it's elements and it will
be impossible to switch the status of the elements while the folder is off.
This callback runs every time the user clicked the mouse left button inside the tree control ( CTreeControl sends us nofification message in the form WM_NOTIFY ) . We will use this event to change node status if the click was done inside the status box . The node status can be changed if this node has no parent with the status set to off this mean that turning off folder state will turn off all it ' s elements and it will be impossible to switch the status of the elements while the folder is off .
void CQATree::OnClickQatree(NMHDR* pNMHDR, LRESULT* pResult)  {
POINT curPos;
UINT flags;
HTREEITEM item;
CTreeNodeInfo* info;
CString query;
CString status;
BSTR    sysQuery;
	GetCursorPos(&curPos);
	m_Tree.ScreenToClient(&curPos);
	item = m_Tree.HitTest(curPos,&flags);
	if(item!=NULL) {
		if( (flags&TVHT_ONITEMICON) !=0 ) {
 	         info=(CTreeNodeInfo *)m_Tree.GetItemData(item);
			 if(info->m_RootEnabled!=FALSE) {
                  query.Format("sev_get {%s} on",info->m_NodeName);
                  sysQuery=query.AllocSysString();
                  status=DataSourceAccessSync(&sysQuery);
                  SysFreeString(sysQuery)
					  ; 
				  if(status=="1") status = "0";
			      else            status = "1";
                  query.Format("sev_set {%s} on %s",info->m_NodeName,status);
                  sysQuery=query.AllocSysString();
                  CString res = DataSourceAccessSync(&sysQuery);
                  SysFreeString(sysQuery); 
	              if(info->m_NodeType=="folder") {
	                 if(status=="1") m_Tree.SetItemImage(item,1,0);
		             else            m_Tree.SetItemImage(item,7,6);
				  }
	              if(info->m_NodeType=="query_0") {
	                 if(status=="1") m_Tree.SetItemImage(item,3,2);
		             else            m_Tree.SetItemImage(item,9,8);
				  }
	              if(info->m_NodeType=="query_1") {
	                 if(status=="1") m_Tree.SetItemImage(item,5,4);
		             else            m_Tree.SetItemImage(item,9,8);
				  }
				  HTREEITEM child=m_Tree.GetChildItem(item);
				  if(child!=NULL) PropagateStatus(child,status=="1");
                  CQAParams* view;
                  view=(CQAParams* )(((CSplitterWnd *)GetParent())->GetPane(0,1));
                  view->FillPropertiesOfNode(info->m_NodeName);
			 }
		}
	}
	*pResult = 0;
}
void CQATree :: OnClickQatree ( NMHDR * pNMHDR , LRESULT * pResult ) { POINT curPos ; UINT flags ; HTREEITEM item ; CTreeNodeInfo * info ; CString query ; CString status ; BSTR sysQuery ; GetCursorPos ( & curPos ) ; m_Tree . ScreenToClient ( & curPos ) ; item = m_Tree . HitTest ( curPos , & flags ) ; if ( item != NULL ) { if ( ( flags & TVHT_ONITEMICON ) != 0 ) { info = ( CTreeNodeInfo * ) m_Tree . GetItemData ( item ) ; if ( info -> m_RootEnabled != FALSE ) { query . Format ( " " , info -> m_NodeName ) ; sysQuery = query . AllocSysString ( ) ; status = DataSourceAccessSync ( & sysQuery ) ; SysFreeString ( sysQuery ) ; if ( status == " " ) status = " " ; else status = " " ; query . Format ( " " , info -> m_NodeName , status ) ; sysQuery = query . AllocSysString ( ) ; CString res = DataSourceAccessSync ( & sysQuery ) ; SysFreeString ( sysQuery ) ; if ( info -> m_NodeType == " " ) { if ( status == " " ) m_Tree . SetItemImage ( item , 1 , 0 ) ; else m_Tree . SetItemImage ( item , 7 , 6 ) ; } if ( info -> m_NodeType == " " ) { if ( status == " " ) m_Tree . SetItemImage ( item , 3 , 2 ) ; else m_Tree . SetItemImage ( item , 9 , 8 ) ; } if ( info -> m_NodeType == " " ) { if ( status == " " ) m_Tree . SetItemImage ( item , 5 , 4 ) ; else m_Tree . SetItemImage ( item , 9 , 8 ) ; } HTREEITEM child = m_Tree . GetChildItem ( item ) ; if ( child != NULL ) PropagateStatus ( child , status == " " ) ; CQAParams * view ; view = ( CQAParams * ) ( ( ( CSplitterWnd * ) GetParent ( ) ) -> GetPane ( 0 , 1 ) ) ; view -> FillPropertiesOfNode ( info -> m_NodeName ) ; } } } * pResult = 0 ; }
This callback runs every time the user clicked the mouse left button inside the tree
control (CTreeControl sends us nofification message in the form WM_NOTIFY).
This callback runs every time the user clicked the mouse left button inside the tree control ( CTreeControl sends us nofification message in the form WM_NOTIFY ) .
// Getting the node status // Switching the status // Setting the node status // Setting the new status according to the parent status and  // the current node status.