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

CFileDialog

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
7 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 Offline
    S Offline
    sarfaraznawaz
    wrote on last edited by
    #1

    how to use the CFileDialog box to open the folder..... i had done to open the .file extension which successfully opening but i am not able to open the folder plz help out this .....

    D L A 3 Replies Last reply
    0
    • S sarfaraznawaz

      how to use the CFileDialog box to open the folder..... i had done to open the .file extension which successfully opening but i am not able to open the folder plz help out this .....

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      sarfaraznawaz wrote:

      how to use the CFileDialog box to open the folder.....

      Why not use SHBrowseForFolder() instead?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

      1 Reply Last reply
      0
      • S sarfaraznawaz

        how to use the CFileDialog box to open the folder..... i had done to open the .file extension which successfully opening but i am not able to open the folder plz help out this .....

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        CFileDialog automatically opens folders as they are selected by the user navigating a directory tree. Perhaps you could clarify your question.

        The best things in life are not things.

        S 1 Reply Last reply
        0
        • L Lost User

          CFileDialog automatically opens folders as they are selected by the user navigating a directory tree. Perhaps you could clarify your question.

          The best things in life are not things.

          S Offline
          S Offline
          sarfaraznawaz
          wrote on last edited by
          #4

          i tried but not able to open or select the particular folder ..... here my code forit void CfolderlockUIDlg::OnBnClickedAdd() { TCHAR szFilters[] = _T (" Allfolders(* *)¦* *¦¦"); CFileDialog dlg (TRUE, _T ("folder "), _T ("folders "),OFN_FILEMUSTEXIST |OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters,this); //CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT ,NULL,NULL,0); if (dlg.DoModal () == IDOK) { filepath = dlg.GetPathName(); m_edit.SetWindowText(filepath); } } by this it shows all the folder but i cant select the or open the folder

          C 1 Reply Last reply
          0
          • S sarfaraznawaz

            i tried but not able to open or select the particular folder ..... here my code forit void CfolderlockUIDlg::OnBnClickedAdd() { TCHAR szFilters[] = _T (" Allfolders(* *)¦* *¦¦"); CFileDialog dlg (TRUE, _T ("folder "), _T ("folders "),OFN_FILEMUSTEXIST |OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters,this); //CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT ,NULL,NULL,0); if (dlg.DoModal () == IDOK) { filepath = dlg.GetPathName(); m_edit.SetWindowText(filepath); } } by this it shows all the folder but i cant select the or open the folder

            C Offline
            C Offline
            Chandrasekharan P
            wrote on last edited by
            #5

            Do you want to select the folder or the the file inside the folder? if its the folder then you can use the function that was mentioned by David here is an example for that

            BROWSEINFO bi;
            ZeroMemory(&bi, sizeof(bi));
            TCHAR szDisplayName[MAX_PATH];
            szDisplayName[0] = '';

            bi.hwndOwner        =   NULL; 
            bi.pidlRoot         =   NULL; 
            bi.pszDisplayName   =   szDisplayName; 
            bi.lpszTitle        =   \_T("Please select a folder for storing received files :"); 
            bi.ulFlags          =   BIF\_RETURNONLYFSDIRS;
            bi.lParam           =   NULL; 
            bi.iImage           =   0;  
            
            LPITEMIDLIST   pidl   =   SHBrowseForFolder(&bi);
            TCHAR   szPathName\[MAX\_PATH\]; 
            if   (NULL   !=   pidl)
            {
                 BOOL bRet = SHGetPathFromIDList(pidl,szPathName);
                 if(FALSE == bRet)
                      return;
                 AfxMessageBox(szPathName);
            }
            

            and if you are selecting a file then you can see this example SelectDialog - A Multiple File and Folder Select Dialog[^]

            S 1 Reply Last reply
            0
            • S sarfaraznawaz

              how to use the CFileDialog box to open the folder..... i had done to open the .file extension which successfully opening but i am not able to open the folder plz help out this .....

              A Offline
              A Offline
              abhishek biradar
              wrote on last edited by
              #6

              CString str; str.Format(_T("All Files (*.dat)|*.dat||"));// change name .dat to any extension you want CFileDialog file_dlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,str); INT_PTR iRet = file_dlg.DoModal(); :)

              1 Reply Last reply
              0
              • C Chandrasekharan P

                Do you want to select the folder or the the file inside the folder? if its the folder then you can use the function that was mentioned by David here is an example for that

                BROWSEINFO bi;
                ZeroMemory(&bi, sizeof(bi));
                TCHAR szDisplayName[MAX_PATH];
                szDisplayName[0] = '';

                bi.hwndOwner        =   NULL; 
                bi.pidlRoot         =   NULL; 
                bi.pszDisplayName   =   szDisplayName; 
                bi.lpszTitle        =   \_T("Please select a folder for storing received files :"); 
                bi.ulFlags          =   BIF\_RETURNONLYFSDIRS;
                bi.lParam           =   NULL; 
                bi.iImage           =   0;  
                
                LPITEMIDLIST   pidl   =   SHBrowseForFolder(&bi);
                TCHAR   szPathName\[MAX\_PATH\]; 
                if   (NULL   !=   pidl)
                {
                     BOOL bRet = SHGetPathFromIDList(pidl,szPathName);
                     if(FALSE == bRet)
                          return;
                     AfxMessageBox(szPathName);
                }
                

                and if you are selecting a file then you can see this example SelectDialog - A Multiple File and Folder Select Dialog[^]

                S Offline
                S Offline
                sarfaraznawaz
                wrote on last edited by
                #7

                thanks its working..... but one thing that its necessary to make browseinfo as zero memory ......

                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