1// BrowseFolders.cpp : implementation file 2// 3 4#include "stdafx.h" 5 6#include "FileSharing.h" 7#include "BrowseFolders.h" 8#include "MTVFolder.h" 9 10#ifdef _DEBUG 11#define new DEBUG_NEW 12#undef THIS_FILE 13static char THIS_FILE[] = __FILE__; 14#endif 15 16///////////////////////////////////////////////////////////////////////////// 17// CBrowseFolders dialog 18 19 20CBrowseFolders::CBrowseFolders(CWnd* pParent /*=NULL*/) 21 : CDialog(CBrowseFolders::IDD, pParent) 22{ 23 //{{AFX_DATA_INIT(CBrowseFolders) 24 // NOTE: the ClassWizard will add member initialization here 25 //}}AFX_DATA_INIT 26 27 m_newPath.Empty(); 28} 29 30 31void CBrowseFolders::DoDataExchange(CDataExchange* pDX) 32{ 33 CDialog::DoDataExchange(pDX); 34 //{{AFX_DATA_MAP(CBrowseFolders) 35 //}}AFX_DATA_MAP 36 DDX_Control(pDX, IDC_FOLDERVIEW, m_folderCtrl); 37} 38 39 40BEGIN_MESSAGE_MAP(CBrowseFolders, CDialog) 41 //{{AFX_MSG_MAP(CBrowseFolders) 42 //}}AFX_MSG_MAP 43END_MESSAGE_MAP() 44 45///////////////////////////////////////////////////////////////////////////// 46// CBrowseFolders message handlers 47 48BOOL CBrowseFolders::OnInitDialog() 49{ 50 CDialog::OnInitDialog(); 51 SetPath(m_newPath); 52 return TRUE; 53} 54 55// SelectFolder() 56// 57int CBrowseFolders::SelectFolder(LPCTSTR lpszPath) 58{ 59 m_newPath = lpszPath; 60 return DoModal(); 61} 62 63// SetPath() 64// 65void CBrowseFolders::SetPath(LPCTSTR lpszPath) 66{ 67 CString string(lpszPath); 68 VARIANT variant; 69 BSTR bstr = string.AllocSysString(); 70 71 variant.vt = VT_BSTR; 72 variant.bstrVal = bstr; 73 74 m_folderCtrl.put_SelectedFolder(variant); 75} 76 77// GetPath() 78// 79CString CBrowseFolders::GetPath() 80{ 81 if (IsWindow(m_folderCtrl.GetSafeHwnd())) 82 { 83 VARIANT var = m_folderCtrl.get_SelectedFolder(); 84 CMTVFolder folder(var.pdispVal); 85 return folder.GetPathName(); 86 } 87 88 return m_newPath; 89} 90 91// OnOK() 92// 93void CBrowseFolders::OnOK() 94{ 95 VARIANT var = m_folderCtrl.get_SelectedFolder(); 96 CMTVFolder folder(var.pdispVal); 97 98 m_newPath = folder.GetPathName(); 99 m_newPath.MakeLower(); 100 101 CDialog::OnOK(); 102} 103