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. CFileDialog i want select only directories

CFileDialog i want select only directories

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 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.
  • T Offline
    T Offline
    tiziacaia
    wrote on last edited by
    #1

    It's possible set a file dialog (CFileDialog) to let select to user only directories? I want to do this to choose the work directory of my software. Somebody can help me? Thanks a lot

    M B 2 Replies Last reply
    0
    • T tiziacaia

      It's possible set a file dialog (CFileDialog) to let select to user only directories? I want to do this to choose the work directory of my software. Somebody can help me? Thanks a lot

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      See the FAQ 4.13 How do I prompt the user to select a directory?[^] --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb

      1 Reply Last reply
      0
      • T tiziacaia

        It's possible set a file dialog (CFileDialog) to let select to user only directories? I want to do this to choose the work directory of my software. Somebody can help me? Thanks a lot

        B Offline
        B Offline
        BlackDice
        wrote on last edited by
        #3

        Or here's a function that i use to return the folder name in a CString:

        CString GetFolder()
        {
                                                       LPMALLOC pMalloc,pMalloc2;
                                                        CString strDirectory;
        			BROWSEINFO bi;
        			CString strPath1,strPath2;
        			/* Gets the Shell's default allocator */
        			char pszBuffer[MAX_PATH];
        			LPITEMIDLIST pidl;
        			// Get help on BROWSEINFO struct - it's got all the bit settings.
        			bi.hwndOwner = GetDesktopWindow();
        			bi.pidlRoot = NULL;
        			bi.pszDisplayName = pszBuffer;
        			bi.lpszTitle = _T("Select First Directory");
        			bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
        			bi.lpfn = NULL;
        			bi.lParam = 0;
        
        			
        			if (::SHGetMalloc(&pMalloc) == NOERROR)
        			{
        				if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
        				{
        					if (::SHGetPathFromIDList(pidl, pszBuffer))
        					{ 
        						strDirectory = pszBuffer;
        					}
        					pMalloc->Free(pidl);
        				}
        				pMalloc->Release();
        			}
                                                        return strDirectory;
        }
        

        If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond

        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