CFileDialog :: Browse folders

后端 未结 6 1050
野性不改
野性不改 2020-12-17 22:39

When I try to instantiate a CFileDialog object it shows both the folders and files. How do you create a CFileDialog that browses for folders alone?

6条回答
  •  独厮守ぢ
    2020-12-17 23:12

    Like someone mentioned, use CFolderPickerDialog which works great. I would like to give you example how to use it especially when using the multi select flag:

    CFolderPickerDialog folderPickerDialog(initialFolder, OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_ENABLESIZING, this,
            sizeof(OPENFILENAME));
    
        CString folderPath;
    
        if (folderPickerDialog.DoModal() == IDOK)
        {
    
            POSITION pos = folderPickerDialog.GetStartPosition();
    
            while (pos)
            {
                folderPath = folderPickerDialog.GetNextPathName(pos);
    
            }
        }
    

提交回复
热议问题