2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ChooseDirDialog.h"
|
|
|
|
#include "NewFolderDialog.h"
|
|
|
|
#include "DiskFSTree.h"
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(ChooseDirDialog, CDialog)
|
2014-11-04 00:26:53 +00:00
|
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_CHOOSEDIR_TREE, OnSelChanged)
|
|
|
|
ON_BN_CLICKED(IDC_CHOOSEDIR_EXPAND_TREE, OnExpandTree)
|
|
|
|
ON_BN_CLICKED(IDC_CHOOSEDIR_NEW_FOLDER, OnNewFolder)
|
|
|
|
ON_WM_HELPINFO()
|
|
|
|
//ON_COMMAND(ID_HELP, OnIDHelp)
|
|
|
|
ON_BN_CLICKED(IDHELP, OnHelp)
|
2007-03-27 17:47:10 +00:00
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
BOOL ChooseDirDialog::OnInitDialog(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
|
|
/* set up the "new folder" button */
|
|
|
|
fNewFolderButton.ReplaceDlgCtrl(this, IDC_CHOOSEDIR_NEW_FOLDER);
|
|
|
|
fNewFolderButton.SetBitmapID(IDB_NEW_FOLDER);
|
|
|
|
|
|
|
|
/* replace the tree control with a ShellTree */
|
|
|
|
if (fShellTree.ReplaceDlgCtrl(this, IDC_CHOOSEDIR_TREE) != TRUE) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("WARNING: ShellTree replacement failed");
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//enable images
|
|
|
|
fShellTree.EnableImages();
|
|
|
|
//populate for the with Shell Folders for the first time
|
|
|
|
fShellTree.PopulateTree(/*CSIDL_DRIVES*/);
|
|
|
|
|
|
|
|
if (fPathName.IsEmpty()) {
|
|
|
|
// start somewhere reasonable
|
|
|
|
fShellTree.ExpandMyComputer();
|
|
|
|
} else {
|
|
|
|
CString msg("");
|
|
|
|
fShellTree.TunnelTree(fPathName, &msg);
|
|
|
|
if (!msg.IsEmpty()) {
|
|
|
|
/* failed */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("TunnelTree failed on '%ls' (%ls), using MyComputer instead",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) fPathName, (LPCWSTR) msg);
|
2014-11-04 00:26:53 +00:00
|
|
|
fShellTree.ExpandMyComputer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fShellTree.SetFocus();
|
|
|
|
return FALSE; // leave focus on shell tree
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
BOOL ChooseDirDialog::PreTranslateMessage(MSG* pMsg)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pMsg->message == WM_KEYDOWN &&
|
2007-03-27 17:47:10 +00:00
|
|
|
pMsg->wParam == VK_RETURN)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("RETURN!");
|
2014-11-04 00:26:53 +00:00
|
|
|
if (GetFocus() == GetDlgItem(IDC_CHOOSEDIR_PATHEDIT)) {
|
|
|
|
OnExpandTree();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void ChooseDirDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString path;
|
|
|
|
CWnd* pWnd = GetDlgItem(IDC_CHOOSEDIR_PATH);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (fShellTree.GetFolderPath(&path))
|
|
|
|
fPathName = path;
|
|
|
|
else
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
fPathName = L"";
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->SetWindowText(fPathName);
|
|
|
|
|
|
|
|
// disable the "Select" button when there's no path ready
|
|
|
|
pWnd = GetDlgItem(IDOK);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->EnableWindow(!fPathName.IsEmpty());
|
|
|
|
|
|
|
|
// It's confusing to have two different paths showing, so wipe out the
|
|
|
|
// free entry field when the selection changes.
|
|
|
|
pWnd = GetDlgItem(IDC_CHOOSEDIR_PATHEDIT);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pWnd->SetWindowText(L"");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
*pResult = 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void ChooseDirDialog::OnExpandTree(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CString str;
|
|
|
|
CString msg;
|
|
|
|
|
|
|
|
pWnd = GetDlgItem(IDC_CHOOSEDIR_PATHEDIT);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowText(str);
|
|
|
|
|
|
|
|
if (!str.IsEmpty()) {
|
|
|
|
fShellTree.TunnelTree(str, &msg);
|
|
|
|
if (!msg.IsEmpty()) {
|
|
|
|
CString failed;
|
|
|
|
failed.LoadString(IDS_FAILED);
|
|
|
|
MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void ChooseDirDialog::OnNewFolder(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
if (fPathName.IsEmpty()) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
MessageBox(L"You can't create a folder in this part of the tree.",
|
|
|
|
L"Bad Location", MB_OK | MB_ICONERROR);
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NewFolderDialog newFolderDlg;
|
|
|
|
|
|
|
|
newFolderDlg.fCurrentFolder = fPathName;
|
|
|
|
if (newFolderDlg.DoModal() == IDOK) {
|
|
|
|
if (newFolderDlg.GetFolderCreated()) {
|
|
|
|
/*
|
|
|
|
* They created a new folder. We want to add it to the tree
|
|
|
|
* and then select it. This is not too hard because we know
|
|
|
|
* that the folder was created under the currently-selected
|
|
|
|
* tree node.
|
|
|
|
*/
|
|
|
|
if (fShellTree.AddFolderAtSelection(newFolderDlg.fNewFolder)) {
|
|
|
|
CString msg;
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Success, tunneling to '%ls'",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) newFolderDlg.fNewFullPath);
|
2014-11-04 00:26:53 +00:00
|
|
|
fShellTree.TunnelTree(newFolderDlg.fNewFullPath, &msg);
|
|
|
|
if (!msg.IsEmpty()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("TunnelTree failed: %ls", (LPCWSTR) msg);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("AddFolderAtSelection FAILED");
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NewFolderDialog returned IDOK but no create");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|