home *** CD-ROM | disk | FTP | other *** search
- // SessionPropertiesMainPage.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "MirrorIt.h"
- #include "SessionPropertiesMainPage.h"
- #include "shlobj.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CSessionPropertiesMainPage property page
-
- IMPLEMENT_DYNCREATE(CSessionPropertiesMainPage, CPropertyPage)
-
- CSessionPropertiesMainPage::CSessionPropertiesMainPage() : CPropertyPage(CSessionPropertiesMainPage::IDD)
- {
- //{{AFX_DATA_INIT(CSessionPropertiesMainPage)
- m_BaseURL = _T("");
- m_SessionName = _T("");
- m_Comment = _T("");
- m_Directory = _T("");
- //}}AFX_DATA_INIT
- }
-
- CSessionPropertiesMainPage::~CSessionPropertiesMainPage()
- {
- }
-
- void CSessionPropertiesMainPage::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSessionPropertiesMainPage)
- DDX_Text(pDX, IDC_BASEURL, m_BaseURL);
- DDX_Text(pDX, IDC_SESSIONNAME, m_SessionName);
- DDX_Text(pDX, IDC_COMMENT, m_Comment);
- DDX_Text(pDX, IDC_DIRECTORY, m_Directory);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CSessionPropertiesMainPage, CPropertyPage)
- //{{AFX_MSG_MAP(CSessionPropertiesMainPage)
- ON_BN_CLICKED(IDC_DIRECTORYBUTTON, OnDirectorybutton)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CSessionPropertiesMainPage message handlers
-
- BOOL CSessionPropertiesMainPage::OnKillActive()
- {
- BOOL bOk = CPropertyPage::OnKillActive();
- if (bOk)
- {
- if (m_SessionName.IsEmpty())
- {
- AfxMessageBox(IDW_SESSIONNAME, MB_OK | MB_ICONSTOP);
- bOk = FALSE;
- }
- }
- return bOk;
- }
-
- void CSessionPropertiesMainPage::OnDirectorybutton()
- {
- CString directory;
-
- GetDlgItemText(IDC_DIRECTORY, directory);
-
- if (BrowseDirectory(m_hWnd, directory))
- SetDlgItemText(IDC_DIRECTORY, directory);
- }
-
- int CSessionPropertiesMainPage::BrowseDirectory(HWND hwnd, CString & directory)
- {
- BROWSEINFO bi;
- LPSTR lpBuffer;
- LPITEMIDLIST pidlDesktop;
- LPITEMIDLIST pidlBrowse;
- LPMALLOC g_pMalloc;
-
- directory.Empty();
- if (!SUCCEEDED(SHGetMalloc(&g_pMalloc)))
- return FALSE;
-
- if ((lpBuffer = (LPSTR) g_pMalloc->Alloc(MAX_PATH)) == NULL)
- {
- g_pMalloc->Release();
- return FALSE;
- }
-
- if (!SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_DESKTOP, &pidlDesktop)))
- {
- g_pMalloc->Free(lpBuffer);
- g_pMalloc->Release();
- return FALSE;
- }
-
- bi.hwndOwner = hwnd;
- bi.pidlRoot = pidlDesktop;
- bi.pszDisplayName = lpBuffer;
-
- CString title;
- title.LoadString(IDC_BROWSEDIR);
- bi.lpszTitle = title;
- bi.ulFlags = BIF_RETURNONLYFSDIRS;
- bi.lpfn = NULL;
- bi.lParam = 0;
-
- int res = FALSE;
- pidlBrowse = SHBrowseForFolder(&bi);
- if (pidlBrowse != NULL)
- {
- if (SHGetPathFromIDList(pidlBrowse, lpBuffer))
- {
- directory = lpBuffer;
- res = TRUE;
- }
- g_pMalloc->Free(pidlBrowse);
- }
- g_pMalloc->Free(pidlDesktop);
- g_pMalloc->Free(lpBuffer);
- g_pMalloc->Release();
- return res;
- }
-