// SettingsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "skoko.h"
#include "SettingsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSettingsDlg dialog


CSettingsDlg::CSettingsDlg(CWnd* pParent /*=NULL*/)
  : CDialog(CSettingsDlg::IDD, pParent)
{
  //{{AFX_DATA_INIT(CSettingsDlg)
  m_tempDir = theApp.m_tempDir;
  //}}AFX_DATA_INIT
}


void CSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
  CDialog::DoDataExchange(pDX);
  //{{AFX_DATA_MAP(CSettingsDlg)
  DDX_Text(pDX, IDC_EDIT_TEMP_DIR, m_tempDir);
  //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingsDlg, CDialog)
  //{{AFX_MSG_MAP(CSettingsDlg)
  ON_BN_CLICKED(IDC_BUTTON_BROWSE_TEMP_DIR, OnButtonBrowseTempDir)
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingsDlg message handlers

void CSettingsDlg::OnButtonBrowseTempDir() 
{
  TCHAR buf[ MAX_PATH ];

  BROWSEINFO bi;
  bi.hwndOwner = GetSafeHwnd();
  bi.pidlRoot = NULL;
  bi.pszDisplayName = buf;
  bi.lpszTitle = _T("Каталог временных файлов");
  bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
  bi.lpfn = NULL;
  bi.lParam = 0;
  bi.iImage = -1;
  LPCITEMIDLIST pIdList = SHBrowseForFolder(&bi);
  if (pIdList && SHGetPathFromIDList(pIdList, buf))
  {
    m_tempDir = buf;
    UpdateData(FALSE);
  }
}
