mirror of
https://github.com/fadden/ciderpress.git
synced 2024-11-23 11:33:58 +00:00
fd37bfd261
The previous version was written to work on Win98+, and used the rather gnarly ShellTree class. Since we no longer support Win98, we can now use CShellManager::BrowseForFolder(), which does exactly what we want without all the ugly code (and it looks nicer, and it integrates better with the rest of the system). We can also get rid of NewFolderDialog, which only existed to allow the user to create a folder when trudging through ShellTree. This required "upgrading" the main app object from CWinApp to CWinAppEx, but that appears to be benign. Tested on WinXP and it all seems fine.
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
/*
|
|
* CiderPress
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
* See the file LICENSE for distribution terms.
|
|
*/
|
|
/*
|
|
* Dialog for choosing a directory.
|
|
*/
|
|
#ifndef APP_CHOOSEDIRDIALOG
|
|
#define APP_CHOOSEDIRDIALOG
|
|
|
|
#include "../util/UtilLib.h"
|
|
#include "resource.h"
|
|
#include <afxshellmanager.h>
|
|
|
|
|
|
/*
|
|
* Choose a directory. This is distinctly different from what the standard
|
|
* "Open" and "Save As" dialogs do, because those want to choose normal files
|
|
* only, while this wants to select a folder.
|
|
*
|
|
* Win2K added the shell "browse for folder" dialog, which does exactly
|
|
* what we want.
|
|
*/
|
|
class ChooseDirDialog {
|
|
public:
|
|
ChooseDirDialog(CWnd* pParent = NULL) {
|
|
fpParent = pParent;
|
|
}
|
|
~ChooseDirDialog() {}
|
|
|
|
// Gets the pathname. Call this after DoModal has updated it.
|
|
const CString& GetPathName(void) const {
|
|
return fPathName;
|
|
}
|
|
|
|
// Sets the pathname. Call before DoModal().
|
|
void SetPathName(const CString& str) {
|
|
fPathName = str;
|
|
}
|
|
|
|
// Returns false if nothing was selected (e.g. the dialog was canceled).
|
|
BOOL DoModal() {
|
|
CShellManager* pMan = gMyApp.GetShellManager();
|
|
CString outFolder;
|
|
BOOL result = pMan->BrowseForFolder(outFolder, fpParent, fPathName,
|
|
L"Select folder:", BIF_RETURNONLYFSDIRS | BIF_USENEWUI);
|
|
fPathName = outFolder;
|
|
return result;
|
|
}
|
|
|
|
private:
|
|
CWnd* fpParent;
|
|
CString fPathName;
|
|
};
|
|
|
|
#endif /*APP_CHOOSEDIRDIALOG*/
|