Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Directories in CTree View

Directories in CTree View

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Sameer Maggon

    Hi, I'am sory, but i guess u misunderstood my problem. Actually i want to display a tree view in which all the directories of the Drive are listed Sameer

    N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #4

    Sameer Maggon wrote: Actually i want to display a tree view in which all the directories of the Drive are listed Sorry :-( What you need is SHBrowseForFolder Nish


    Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

    P S 2 Replies Last reply
    0
    • N Nish Nishant

      Sameer Maggon wrote: Actually i want to display a tree view in which all the directories of the Drive are listed Sorry :-( What you need is SHBrowseForFolder Nish


      Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

      P Offline
      P Offline
      Prem Kumar
      wrote on last edited by
      #5

      look at the foll,. article at Codeguru http://www.codeguru.com/treeview/CDirTreeCtrl.shtml

      S 1 Reply Last reply
      0
      • P Prem Kumar

        look at the foll,. article at Codeguru http://www.codeguru.com/treeview/CDirTreeCtrl.shtml

        S Offline
        S Offline
        Sameer Maggon
        wrote on last edited by
        #6

        Hi, I saw that Control, but that control is too heavy. I just want to Display the Directories and not the Files etc. Actually i just want to give a user, selection of a Directory. Please help Sameer

        N A P 3 Replies Last reply
        0
        • S Sameer Maggon

          Hi, I saw that Control, but that control is too heavy. I just want to Display the Directories and not the Files etc. Actually i just want to give a user, selection of a Directory. Please help Sameer

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #7

          Sameer Maggon wrote: Actually i just want to give a user, selection of a Directory. Already told you. Use SHBrowseForFolder Nish


          Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

          1 Reply Last reply
          0
          • S Sameer Maggon

            Hi, I saw that Control, but that control is too heavy. I just want to Display the Directories and not the Files etc. Actually i just want to give a user, selection of a Directory. Please help Sameer

            A Offline
            A Offline
            Alexandru Savescu
            wrote on last edited by
            #8

            You can limit the tree to one level. Best regards, Alexandru Savescu

            1 Reply Last reply
            0
            • S Sameer Maggon

              Hi, I saw that Control, but that control is too heavy. I just want to Display the Directories and not the Files etc. Actually i just want to give a user, selection of a Directory. Please help Sameer

              P Offline
              P Offline
              Prem Kumar
              wrote on last edited by
              #9

              Use the foll. code

              CString GetUserDirectory()
              {
              CString strPath ;
              char szDisplayName[_MAX_PATH] ;
              char *szPath = NULL ;
              char *szTitle = _T(" Please Locate Directory : ") ;//Title of Locate Dialog

              BROWSEINFO bi = {0} ; //Init to NULL,so we do not have to fill up some members explicitly to NULL
              
              bi.pszDisplayName	= &szDisplayName\[0\] ;
              bi.lpszTitle		= szTitle ;
              bi.ulFlags		= BIF\_RETURNONLYFSDIRS | BIF\_RETURNFSANCESTORS ;
              bi.hwndOwner		= NULL ;
              
              LPITEMIDLIST pidl = SHBrowseForFolder(&bi) ;
              if( pidl == NULL ) //User has cancelled operation
              	return strPath ;
              
              //Error Check 
              if( !SHGetPathFromIDList(pidl,szPath) )
              {
              	AfxMessageBox(" The Path is Invalid ! ") ;
              	return strPath ;
              }
              //Release the PIDL thru Shells MAlloc
              IMalloc \*pMalloc = NULL ;
              HRESULT hr =  SHGetMalloc(&pMalloc) ;
              if( !SUCCEEDED(hr) )
              	return strPath ;
              
              pMalloc->Free( (void\*)pidl ) ;//Release the PIDL
              pMalloc->Release() ;//Release the Interface 
              
              strPath = szPath ;//The Path to the Directory
              return strPath ;
              

              }

              S 2 Replies Last reply
              0
              • N Nish Nishant

                Sameer Maggon wrote: Actually i want to display a tree view in which all the directories of the Drive are listed Sorry :-( What you need is SHBrowseForFolder Nish


                Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                S Offline
                S Offline
                Sameer Maggon
                wrote on last edited by
                #10

                Thanx a lot Nish. This solves my problem :)

                1 Reply Last reply
                0
                • P Prem Kumar

                  Use the foll. code

                  CString GetUserDirectory()
                  {
                  CString strPath ;
                  char szDisplayName[_MAX_PATH] ;
                  char *szPath = NULL ;
                  char *szTitle = _T(" Please Locate Directory : ") ;//Title of Locate Dialog

                  BROWSEINFO bi = {0} ; //Init to NULL,so we do not have to fill up some members explicitly to NULL
                  
                  bi.pszDisplayName	= &szDisplayName\[0\] ;
                  bi.lpszTitle		= szTitle ;
                  bi.ulFlags		= BIF\_RETURNONLYFSDIRS | BIF\_RETURNFSANCESTORS ;
                  bi.hwndOwner		= NULL ;
                  
                  LPITEMIDLIST pidl = SHBrowseForFolder(&bi) ;
                  if( pidl == NULL ) //User has cancelled operation
                  	return strPath ;
                  
                  //Error Check 
                  if( !SHGetPathFromIDList(pidl,szPath) )
                  {
                  	AfxMessageBox(" The Path is Invalid ! ") ;
                  	return strPath ;
                  }
                  //Release the PIDL thru Shells MAlloc
                  IMalloc \*pMalloc = NULL ;
                  HRESULT hr =  SHGetMalloc(&pMalloc) ;
                  if( !SUCCEEDED(hr) )
                  	return strPath ;
                  
                  pMalloc->Free( (void\*)pidl ) ;//Release the PIDL
                  pMalloc->Release() ;//Release the Interface 
                  
                  strPath = szPath ;//The Path to the Directory
                  return strPath ;
                  

                  }

                  S Offline
                  S Offline
                  Sameer Maggon
                  wrote on last edited by
                  #11

                  Thanx for the code, but i had already written the application using MSDN.. Thanx a lot again for the help. Regards Sameer

                  1 Reply Last reply
                  0
                  • P Prem Kumar

                    Use the foll. code

                    CString GetUserDirectory()
                    {
                    CString strPath ;
                    char szDisplayName[_MAX_PATH] ;
                    char *szPath = NULL ;
                    char *szTitle = _T(" Please Locate Directory : ") ;//Title of Locate Dialog

                    BROWSEINFO bi = {0} ; //Init to NULL,so we do not have to fill up some members explicitly to NULL
                    
                    bi.pszDisplayName	= &szDisplayName\[0\] ;
                    bi.lpszTitle		= szTitle ;
                    bi.ulFlags		= BIF\_RETURNONLYFSDIRS | BIF\_RETURNFSANCESTORS ;
                    bi.hwndOwner		= NULL ;
                    
                    LPITEMIDLIST pidl = SHBrowseForFolder(&bi) ;
                    if( pidl == NULL ) //User has cancelled operation
                    	return strPath ;
                    
                    //Error Check 
                    if( !SHGetPathFromIDList(pidl,szPath) )
                    {
                    	AfxMessageBox(" The Path is Invalid ! ") ;
                    	return strPath ;
                    }
                    //Release the PIDL thru Shells MAlloc
                    IMalloc \*pMalloc = NULL ;
                    HRESULT hr =  SHGetMalloc(&pMalloc) ;
                    if( !SUCCEEDED(hr) )
                    	return strPath ;
                    
                    pMalloc->Free( (void\*)pidl ) ;//Release the PIDL
                    pMalloc->Release() ;//Release the Interface 
                    
                    strPath = szPath ;//The Path to the Directory
                    return strPath ;
                    

                    }

                    S Offline
                    S Offline
                    Sameer Maggon
                    wrote on last edited by
                    #12

                    Do I have to CoInitialize() and Uninitialize() ???

                    1 Reply Last reply
                    0
                    • S Sameer Maggon

                      Hi, I want to show all the directory (directory structure) in the Tree View How can i do that Sameer

                      R Offline
                      R Offline
                      Ravi Bhavnani
                      wrote on last edited by
                      #13

                      See this article. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups