// VolumeInfoDlg.cpp : 구현 파일입니다.
//

#include "stdafx.h"
#include "ConsoleApp.h"
#include "VolumeInfoDlg.h"

// CVolumeInfoDlg 대화 상자입니다.

IMPLEMENT_DYNAMIC(CVolumeInfoDlg, CDialog)
CVolumeInfoDlg::CVolumeInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CVolumeInfoDlg::IDD, pParent)
	, m_sTitle(_T(""))
	, m_sType(_T(""))
	, m_sUseSpace(_T(""))
	, m_sUseSpaceT(_T(""))
	, m_sFreeSpace(_T(""))
	, m_sFreeSpaceT(_T(""))
	, m_sTotalSpace(_T(""))
	, m_sTotalSpaceT(_T(""))
{
}

CVolumeInfoDlg::~CVolumeInfoDlg()
{
}

void CVolumeInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_STC_ICON, m_stcIcon);
	DDX_Text(pDX, IDC_EDT_TITLE, m_sTitle);
	DDX_Text(pDX, IDC_STC_TYPE, m_sType);
	DDX_Text(pDX, IDC_STC_USESPACE, m_sUseSpace);
	DDX_Text(pDX, IDC_STC_USESPACET, m_sUseSpaceT);
	DDX_Text(pDX, IDC_STC_FREESPACE, m_sFreeSpace);
	DDX_Text(pDX, IDC_STC_FREESPACET, m_sFreeSpaceT);
	DDX_Text(pDX, IDC_STC_TOTALSPACE, m_sTotalSpace);
	DDX_Text(pDX, IDC_STC_TOTALSPACET, m_sTotalSpaceT);
}


BEGIN_MESSAGE_MAP(CVolumeInfoDlg, CDialog)
	ON_WM_DESTROY()
END_MESSAGE_MAP()


// CVolumeInfoDlg 메시지 처리기입니다.

BOOL CVolumeInfoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	SHFILEINFO shfi;

	if (!SHGetFileInfo(m_sType == "폴더" ? "" : "C:\\", FILE_ATTRIBUTE_DIRECTORY, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON))
        shfi.iIcon = 1;
	m_stcIcon.SetIcon(shfi.hIcon);

	if (m_sType == "폴더") {
		GetDlgItem(IDC_STC_USETITLE)->SetWindowText("크기 : ");

		GetDlgItem(IDC_STC_FREETITLE)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_STC_FREESPACE)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_STC_FREESPACET)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_STC_TOTALTITLE)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_STC_TOTALSPACE)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_STC_TOTALSPACET)->ShowWindow(SW_HIDE);

		SetWindowText("폴더정보");
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}

void CVolumeInfoDlg::OnDestroy()
{
	CDialog::OnDestroy();

	HICON hIcon;

	hIcon = m_stcIcon.GetIcon();
	if (hIcon)
		DestroyIcon(hIcon);
}
