Creating a directory selection dialog
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Creating a directory selection dialog

  1. #1
    Join Date
    Sep 2002
    Location
    Czech Republic
    Posts
    47

    Creating a directory selection dialog

    Hello,
    does anybody know how to create a dialog, similar to File Open or Save As dialogs, that would enable me to select a directory? I need a dialog where the user could choose a directory into which the output files of the application will be saved. I suppose such dialog should be possible to create by setting some parameters in the CFileDialog::CFileDialog() constructor. Anyway, I tried searching the MSDN and haven't found anything yet.

    thanks for your answer,

    Koxin

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211
    use this...

    Code:
    	if ( <Object Of this class>.GetFolder(<string to receive which folder is selected>, "Any string.", this->m_hWnd, NULL, NULL))
    	{
    		if (!<string to receive which folder is selected>.IsEmpty())
    		{
    Thats how you can use it. Have fun

  3. #3
    Join Date
    Jan 2004
    Location
    Altos
    Posts
    168
    herez the code which will let u do that
    Code:
    if (::SHGetPathFromIDList(lpItemIDList, szBuffer))
         {
            // At this point, szBuffer contains the path 
            // the user chose.
            if (szBuffer[0] == '\0')
            {
               // SHGetPathFromIDList failed, or
               // SHBrowseForFolder failed.
               AfxMessageBox(IDP_FAILED_GET_DIRECTORY,
                  MB_ICONSTOP|MB_OK);
               return strResult;
            }
         
            // We have a path in szBuffer!
            // Return it.
            strResult = szBuffer;
            return strResult;
         }
         else
         {
            // The thing referred to by lpItemIDList 
            // might not have been a file system object.
            // For whatever reason, SHGetPathFromIDList
            // didn't work!
            AfxMessageBox(IDP_FAILED_GET_DIRECTORY,
               MB_ICONSTOP|MB_OK);
            return strResult; // strResult is empty 
         }
    nd if u need documentation search for "browse for folder non-com way"
    string in MSDN library. It will give u watever u require.
    "I came"
    "I saw"
    "I conquered"

  4. #4
    Join Date
    Jan 2004
    Location
    Altos
    Posts
    168

    Talking

    oops m late by few secs
    "I came"
    "I saw"
    "I conquered"

  5. #5
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Smile

    doesn't make a difference, its not a competition man
    have fun...

  6. #6
    Join Date
    Sep 2002
    Location
    Czech Republic
    Posts
    47

    Works perfectly

    thanks agin guys!!!!!!

    Koxin

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center