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. how to show browse button?

how to show browse button?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
9 Posts 4 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.
  • P Offline
    P Offline
    puppya
    wrote on last edited by
    #1

    i want to show browse button on a dialog box application and i want to select a folder not file. how can i implement for browse control for selecting folder? thanks in advance.

    H 1 Reply Last reply
    0
    • P puppya

      i want to show browse button on a dialog box application and i want to select a folder not file. how can i implement for browse control for selecting folder? thanks in advance.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      You can use of SHBrowseForFolder.

      P 1 Reply Last reply
      0
      • H Hamid Taebi

        You can use of SHBrowseForFolder.

        P Offline
        P Offline
        puppya
        wrote on last edited by
        #3

        thanks Hamid for replying me. Could u plz tell me whether i can get some sample code or sample project for browse control?

        H 1 Reply Last reply
        0
        • P puppya

          thanks Hamid for replying me. Could u plz tell me whether i can get some sample code or sample project for browse control?

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          XBrowseForFolder - Wrapper for SHBrowseForFolder[^].

          P 1 Reply Last reply
          0
          • H Hamid Taebi

            XBrowseForFolder - Wrapper for SHBrowseForFolder[^].

            P Offline
            P Offline
            puppya
            wrote on last edited by
            #5

            hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?

            H K D 3 Replies Last reply
            0
            • P puppya

              hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Why you dont use of SHBrowseForFolder it simple to use.

              P 1 Reply Last reply
              0
              • H Hamid Taebi

                Why you dont use of SHBrowseForFolder it simple to use.

                P Offline
                P Offline
                puppya
                wrote on last edited by
                #7

                thanks Hamid, yaa i could implement that using SHBrowseForFolder.

                1 Reply Last reply
                0
                • P puppya

                  hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?

                  K Offline
                  K Offline
                  kamalesh82
                  wrote on last edited by
                  #8

                  I hope this little sample code will help you if you want to select the folder, void CFolderSelectionDlg::OnBrowseClick() { BROWSEINFO brwsInfo; ZeroMemory(&brwsInfo,sizeof(BROWSEINFO)); int iImage = 0; char szFolderPath[MAX_PATH]; char szTitle[255]; memset(szFolderPath,'\0',sizeof(szFolderPath)); memset(szTitle,'\0',sizeof(szTitle)); brwsInfo.hwndOwner = GetSafeHwnd(); brwsInfo.iImage = iImage; brwsInfo.lpfn = NULL; brwsInfo.pidlRoot = NULL; brwsInfo.pszDisplayName = szFolderPath; brwsInfo.lpszTitle = szTitle; //InitCommonControls(); ITEMIDLIST *ptrItemList = SHBrowseForFolder(&brwsInfo); if(ptrItemList != NULL) m_strFolderPath = szFolderPath; UpdateData(FALSE); } this is the simplest. if you want all advanced functionality, you should inherit yoour custom fileDialog class. please go thourh the MSDN.you have to write your version of virtual void OnFolderChange(); virtual BOOL OnFileNameOK(); best of luck...

                  kamalesh

                  1 Reply Last reply
                  0
                  • P puppya

                    hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?

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

                    Anjali Patil wrote:

                    now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?

                    You were suggested to use SHBrowseForFolder(). Why show code that does otherwise? :confused:

                    "Love people and use things, not love things and use people." - Unknown

                    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                    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