summaryrefslogtreecommitdiff
path: root/NSCmpts/BackupDestProp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NSCmpts/BackupDestProp.cpp')
-rw-r--r--NSCmpts/BackupDestProp.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/NSCmpts/BackupDestProp.cpp b/NSCmpts/BackupDestProp.cpp
new file mode 100644
index 0000000..6153945
--- /dev/null
+++ b/NSCmpts/BackupDestProp.cpp
@@ -0,0 +1,67 @@
+// BackupDestProp.cpp : Implementation of CBackupDestProp
+#include "stdafx.h"
+#include "NSCmpts.h"
+#include "BackupDestProp.h"
+
+#include <path.h>
+#include <shlobj.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// CBackupDestProp
+
+LRESULT CBackupDestProp::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Let it choose an object to get data from
+ m_Data.Initialize(m_nObjects, m_ppUnk);
+
+ // Set Control Text
+ m_sPath = m_Data.GetString(NS_BACKUP_REG_DEST, _T(""));
+ SetDlgItemText(IDC_DEST, m_sPath);
+
+ return TRUE; // Let the system set the focus
+}
+
+LRESULT CBackupDestProp::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Last resort. Save text in case of Destroy somewhere
+ GetDlgItemText(IDC_DEST, m_sPath.get_buffer(MAX_PATH), MAX_PATH);
+ m_sPath.release_buffer();
+
+ return 0;
+}
+
+LRESULT CBackupDestProp::OnBrowse(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ // Show a Browse for Folder Dialog
+
+ LPMALLOC pMalloc;
+ if(FAILED(::SHGetMalloc(&pMalloc)))
+ return 0;
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = m_sPath.get_buffer(MAX_PATH);
+ bi.lpszTitle = _T("Choose folder to backup to:");
+ bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+
+ LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
+
+ if(pidl == NULL)
+ return 0;
+
+ m_sPath.release_buffer();
+
+ if(::SHGetPathFromIDList(pidl, m_sPath.get_buffer(MAX_PATH)))
+ ::SetWindowText(GetDlgItem(IDC_DEST), m_sPath);
+
+ m_sPath.release_buffer();
+
+ pMalloc->Free(pidl);
+ pMalloc->Release();
+
+ bHandled = true;
+ return 0;
+}