dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: pass HTREEITEM

  1. #1
    Join Date
    Nov 2007
    Posts
    12

    pass HTREEITEM

    Hi All-

    I am trying to pass an HTREEITEM to a function such that the destination function has a parent to add other HTREEITEMs to. The idea here is that in the end I am trying to make a recursive function to build folders deeper and deeper into a CTreeCtrl. Right now when I pass the parent HTREEITEM the function says that the variable is uninitialized. Am I doing this wrong? is there another way for me to get the parent?

    Code:
    void CDlg_Insp_AOI::getFolders(CString name)
    {
    	PgArchivePrefsSet* pSet = new PgArchivePrefsSet();
    	if (pSet->IsOpen() )     
    		pSet->Close();       
    
    	//  this opens the 'fields' table and selects the records for 
    	//  which 'isFolder' is 'Yes'.   This yields a list of 
    	//  folders.
    
    	CString SQLstatement;							
    	SQLstatement= "isFolder='yes' AND parent='"+name+"'";			//set the filter variable
     
    	pSet->m_strFilter = SQLstatement;		
    	pSet->Open();
    	pSet->MoveFirst();
    	while (! pSet->IsEOF() )
    	{   
    		HTREEITEM hFolder = m_prefsTree.InsertItem(pSet->m_field_name,0,0,TVI_ROOT);
    		getChildFolders(hFolder, pSet->m_field_name);
    		pSet->MoveNext();
    	}      
    	pSet->Close();
    	delete pSet;
    }
    
    void CDlg_Insp_AOI::getChildFolders(HTREEITEM hFolder, CString name)
    {
    	PgArchivePrefsSet* pSet = new PgArchivePrefsSet();
    	if (pSet->IsOpen() )     
    		pSet->Close();       
    
    	//  this opens the 'fields' table and selects the records for 
    	//  which 'isFolder' is 'Yes'.   This yields a list of 
    	//  folders.
    
    	CString SQLstatement;							
    	SQLstatement= "isFolder='yes' AND parent='"+name+"'";			//set the filter variable
     
    	pSet->m_strFilter = SQLstatement;		
    	pSet->Open();
    	pSet->MoveFirst();
    
    	while (! pSet->IsEOF() )
    	{   
    		HTREEITEM hFolder = m_prefsTree.InsertItem(pSet->m_field_name,0,0,hFolder);
    		pSet->MoveNext();
    	}      
    	pSet->Close();
    	delete pSet;
    }
    thanks,
    Michael

  2. #2
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863

    Re: pass HTREEITEM

    Code:
    void CDlg_Insp_AOI::getChildFolders(HTREEITEM hFolder , CString name)
    {
    	PgArchivePrefsSet* pSet = new PgArchivePrefsSet();
    	if (pSet->IsOpen() )     
    		pSet->Close();       
    
    	//  this opens the 'fields' table and selects the records for 
    	//  which 'isFolder' is 'Yes'.   This yields a list of 
    	//  folders.
    
    	CString SQLstatement;							
    	SQLstatement= "isFolder='yes' AND parent='"+name+"'";			//set the filter variable
     
    	pSet->m_strFilter = SQLstatement;		
    	pSet->Open();
    	pSet->MoveFirst();
    
    	while (! pSet->IsEOF() )
    	{   
    
    		HTREEITEM hFolder = m_prefsTree.InsertItem(pSet->m_field_name,0,0,hFolder );
    		pSet->MoveNext();
    	}      
    	pSet->Close();
    	delete pSet;
    }
    the name of the variable passed in and the temp variable are the same, change one.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)