summaryrefslogtreecommitdiffstats
path: root/Source/MFCDialog
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-08 17:40:08 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-08 17:40:08 (GMT)
commit17d7ff0358e14f4b3f7bd1d2f3a877315fa6d0dc (patch)
tree558a174d81af412ce515a07fca26f75dcb831004 /Source/MFCDialog
parent237f960c8932f76c05110c93facdd86bd50bb74e (diff)
downloadCMake-17d7ff0358e14f4b3f7bd1d2f3a877315fa6d0dc.zip
CMake-17d7ff0358e14f4b3f7bd1d2f3a877315fa6d0dc.tar.gz
CMake-17d7ff0358e14f4b3f7bd1d2f3a877315fa6d0dc.tar.bz2
ENH: add initial path support for file choosers
Diffstat (limited to 'Source/MFCDialog')
-rw-r--r--Source/MFCDialog/PropertyList.cpp51
1 files changed, 44 insertions, 7 deletions
diff --git a/Source/MFCDialog/PropertyList.cpp b/Source/MFCDialog/PropertyList.cpp
index 1dda079..102c828 100644
--- a/Source/MFCDialog/PropertyList.cpp
+++ b/Source/MFCDialog/PropertyList.cpp
@@ -381,6 +381,21 @@ void CPropertyList::OnCheckBox()
m_Dirty = true;
}
+// Insane Microsoft way of setting the initial directory
+// for the Shbrowseforfolder function...
+// SetSelProc
+// Callback procedure to set the initial selection of the browser.
+
+int CALLBACK SetSelProc( HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM
+ lpData )
+{
+ if (uMsg==BFFM_INITIALIZED)
+ {
+ ::SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lpData );
+ }
+ return 0;
+}
+
void CPropertyList::OnButton()
{
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
@@ -426,17 +441,26 @@ void CPropertyList::OnButton()
else if (pItem->m_nItemType == CPropertyList::FILE)
{
CString SelectedFile;
- CString Filter("Gif Files (*.gif)|*.gif||");
+ CString Filter("All Files (*.*)||");
CFileDialog FileDlg(TRUE, NULL, NULL, NULL,
Filter);
-
+ CString initialDir;
CString currPath = pItem->m_curValue;
+ if (currPath.GetLength() > 0)
+ {
+ int endSlash = currPath.ReverseFind('\\');
+ if(endSlash == -1)
+ {
+ endSlash = currPath.ReverseFind('/');
+ }
+ initialDir = currPath.Left(endSlash);
+ }
+ initialDir.Replace("/", "\\");
FileDlg.m_ofn.lpstrTitle = "Select file";
if (currPath.GetLength() > 0)
- FileDlg.m_ofn.lpstrInitialDir = currPath.Left(
- currPath.GetLength() - currPath.ReverseFind('\\'));
-
+ FileDlg.m_ofn.lpstrInitialDir = initialDir;
+
if(IDOK == FileDlg.DoModal())
{
SelectedFile = FileDlg.GetPathName();
@@ -450,15 +474,28 @@ void CPropertyList::OnButton()
}
else if (pItem->m_nItemType == CPropertyList::PATH)
{
+ CString initialDir;
+ CString currPath = pItem->m_curValue;
+ if (currPath.GetLength() > 0)
+ {
+ int endSlash = currPath.ReverseFind('\\');
+ if(endSlash == -1)
+ {
+ endSlash = currPath.ReverseFind('/');
+ }
+ initialDir = currPath.Left(endSlash);
+ }
+ initialDir.Replace("/", "\\");
char szPathName[4096];
BROWSEINFO bi;
-
+ bi.lpfn = SetSelProc;
+ bi.lParam = (LPARAM)(LPCSTR) initialDir;
+
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPTSTR)szPathName;
bi.lpszTitle = "Select Directory";
bi.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS;
- bi.lpfn = NULL;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);