newntui/activex/projecttree/src/projecttreectl.cpp
//---------------------------------------------------------------------------------------------------------
// This recursivly called function will attach to the attach_to node all projname childs and for every 
// child it will call itself.
//---------------------------------------------------------------------------------------------------------
This recursivly called function will attach to the attach_to node all projname childs and for every
child it will call itself.
This recursivly called function will attach to the attach_to node all projname childs and for every child it will call itself .
void CProjectTreeCtrl::FillChilds(CString varname, int index, HTREEITEM attach_to) {
CString sizeString;
static int level=0;
	if(index==0) {  
		EvaluateSync(CString("set projlist [roots]"));
		EvaluateSync(CString("size $projlist"),&sizeString);
		unsigned int n=atoi(sizeString);
		if(n>0) {
           TV_ITEM tvItem;
	       tvItem.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
           CProjectPath path;
		   path.Name = "/";
		   path.Id   = 0;
		   POSITION at = m_FullNameList.AddTail(path);
	       tvItem.lParam         = (LPARAM)&m_FullNameList.GetAt(at);
           tvItem.pszText        = "/";
	       tvItem.cchTextMax     = 1;
	       tvItem.iImage         = 0;
	       tvItem.iSelectedImage = 1;
 	       TV_INSERTSTRUCT tvInsert;
	       tvInsert.hParent      = TVI_ROOT;
	       tvInsert.hInsertAfter = TVI_LAST;
	       tvInsert.item         = tvItem;
	       HTREEITEM root = m_Tree.InsertItem(&tvInsert);
	       m_FullNameList.GetAt(at).Id=root;
		   attach_to=root;
		}
	} else {              
		CString serverCall;
        serverCall.Format("set projlist%u [subprojects %s %d]",attach_to,varname,index);
		EvaluateSync(serverCall);
	}
	if(index==0) {
       EvaluateSync(CString("size $projlist"),&sizeString);
	} else {
	   CString num;
	   num.Format("size $projlist%u",attach_to);
	   EvaluateSync(num,&sizeString);
	}
	unsigned int elements=atoi(sizeString);
	for(unsigned int i=1;i<=elements;i++) {
		CString nameRequest;
		CString nameReturned;
		if(index==0) {
		    nameRequest.Format("name $projlist %u",i);
		} else {
		    nameRequest.Format("name $projlist%u %u",attach_to,i);
		}
		EvaluateSync(nameRequest,&nameReturned);
	    int pos=nameReturned.ReverseFind('/');
	    pos++;
		if(nameReturned[pos]!='.') {
            CProjectPath path;
		    path.Name = nameReturned;
		    path.Id   = 0;
            TV_ITEM tvItem;
	        tvItem.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
		    POSITION at = m_FullNameList.AddTail(path);
	        tvItem.lParam         = (LPARAM)&m_FullNameList.GetAt(at);
            tvItem.pszText        = ((char *)(LPCSTR)nameReturned)+pos;
	        tvItem.cchTextMax     = sizeof(nameReturned);
	        tvItem.iImage         = 0;
	        tvItem.iSelectedImage = 1;
 	        TV_INSERTSTRUCT tvInsert;
	        tvInsert.hParent      = attach_to;
	        tvInsert.hInsertAfter = TVI_LAST;
	        tvInsert.item         = tvItem;
	        HTREEITEM root = m_Tree.InsertItem(&tvInsert);
	        m_FullNameList.GetAt(at).Id=root;
		    if(level<50) {
		       level++;
		       CString var;
		       if(index==0) {
			       var="$projlist";
			   } else {
		          var.Format("$projlist%u",attach_to);
			   }
               FillChilds(var,i,root);
		       level--;
			}
		}
	}
	if(index==NULL) EvaluateSync(CString("unset projlist"));
	else {
		CString unset;
		unset.Format("unset projlist%u",attach_to);
		EvaluateSync(unset);
	}
}
void CProjectTreeCtrl :: FillChilds ( CString varname , int index , HTREEITEM attach_to ) { CString sizeString ; static int level = 0 ; if ( index == 0 ) { EvaluateSync ( CString ( " " ) ) ; EvaluateSync ( CString ( " " ) , & sizeString ) ; unsigned int n = atoi ( sizeString ) ; if ( n > 0 ) { TV_ITEM tvItem ; tvItem . mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM ; CProjectPath path ; path . Name = " " ; path . Id = 0 ; POSITION at = m_FullNameList . AddTail ( path ) ; tvItem . lParam = ( LPARAM ) & m_FullNameList . GetAt ( at ) ; tvItem . pszText = " " ; tvItem . cchTextMax = 1 ; tvItem . iImage = 0 ; tvItem . iSelectedImage = 1 ; TV_INSERTSTRUCT tvInsert ; tvInsert . hParent = TVI_ROOT ; tvInsert . hInsertAfter = TVI_LAST ; tvInsert . item = tvItem ; HTREEITEM root = m_Tree . InsertItem ( & tvInsert ) ; m_FullNameList . GetAt ( at ) . Id = root ; attach_to = root ; } } else { CString serverCall ; serverCall . Format ( " " , attach_to , varname , index ) ; EvaluateSync ( serverCall ) ; } if ( index == 0 ) { EvaluateSync ( CString ( " " ) , & sizeString ) ; } else { CString num ; num . Format ( " " , attach_to ) ; EvaluateSync ( num , & sizeString ) ; } unsigned int elements = atoi ( sizeString ) ; for ( unsigned int i = 1 ; i <= elements ; i ++ ) { CString nameRequest ; CString nameReturned ; if ( index == 0 ) { nameRequest . Format ( " " , i ) ; } else { nameRequest . Format ( " " , attach_to , i ) ; } EvaluateSync ( nameRequest , & nameReturned ) ; int pos = nameReturned . ReverseFind ( ' ' ) ; pos ++ ; if ( nameReturned [ pos ] != ' ' ) { CProjectPath path ; path . Name = nameReturned ; path . Id = 0 ; TV_ITEM tvItem ; tvItem . mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM ; POSITION at = m_FullNameList . AddTail ( path ) ; tvItem . lParam = ( LPARAM ) & m_FullNameList . GetAt ( at ) ; tvItem . pszText = ( ( char * ) ( LPCSTR ) nameReturned ) + pos ; tvItem . cchTextMax = sizeof ( nameReturned ) ; tvItem . iImage = 0 ; tvItem . iSelectedImage = 1 ; TV_INSERTSTRUCT tvInsert ; tvInsert . hParent = attach_to ; tvInsert . hInsertAfter = TVI_LAST ; tvInsert . item = tvItem ; HTREEITEM root = m_Tree . InsertItem ( & tvInsert ) ; m_FullNameList . GetAt ( at ) . Id = root ; if ( level < 50 ) { level ++ ; CString var ; if ( index == 0 ) { var = " " ; } else { var . Format ( " " , attach_to ) ; } FillChilds ( var , i , root ) ; level -- ; } } } if ( index == NULL ) EvaluateSync ( CString ( " " ) ) ; else { CString unset ; unset . Format ( " " , attach_to ) ; EvaluateSync ( unset ) ; } }
This recursivly called function will attach to the attach_to node all projname childs and for every
child it will call itself.
This recursivly called function will attach to the attach_to node all projname childs and for every child it will call itself .
// root projects requested //------- Inserting item into the project tree ------------ //--------------------------------------------------------- // childs projects requested //------- Inserting item into the project tree ------------ //--------------------------------------------------------- // Recursive call to fill this child children // Server will remove Set for current subproject storage