CFileDialog :: Browse folders

后端 未结 6 1061
野性不改
野性不改 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:24

    Starting from Vista it's recommended to use IFileDialog with the FOS_PICKFOLDERS option (see msdn):

    CFileDialog od(TRUE/*bOpenFileDialog*/, NULL, NULL,
          OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT , NULL, NULL, 0,
          TRUE/*bVistaStyle*/);
       IFileOpenDialog * openDlgPtr = od.GetIFileOpenDialog();
       if ( openDlgPtr != NULL )
       {
          openDlgPtr->SetOptions(FOS_PICKFOLDERS);
          openDlgPtr->Release();
       }
    
       od.DoModal();
    

提交回复
热议问题