// Demo3Dlg.cpp : 实现文件
//

#include "stdafx.h"
#include "Demo3.h"
#include "Demo3Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CDemo3Dlg 对话框

CDemo3Dlg::CDemo3Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDemo3Dlg::IDD, pParent)
	, m_strFileName(_T(""))
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDemo3Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, m_strFileName);
}

BEGIN_MESSAGE_MAP(CDemo3Dlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
	ON_WM_SIZE()
#endif
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, &CDemo3Dlg::OnBnClickedButton1)
END_MESSAGE_MAP()


// CDemo3Dlg 消息处理程序

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

	// 设置此对话框的图标。当应用程序主窗口不是对话框时，框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	
	return TRUE;  // 除非将焦点设置到控件，否则返回 TRUE
}

#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CDemo3Dlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
	DRA::RelayoutDialog(
		AfxGetInstanceHandle(), 
		this->m_hWnd, 
		DRA::GetDisplayMode() != DRA::Portrait ? 
			MAKEINTRESOURCE(IDD_DEMO3_DIALOG_WIDE) : 
			MAKEINTRESOURCE(IDD_DEMO3_DIALOG));
}
#endif


void CDemo3Dlg::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	OPENFILENAMEEX  ofnex   = {0};
    BOOL            bResult = FALSE;

    ofnex.lStructSize   = sizeof(ofnex);
    ofnex.ExFlags       = OFN_EXFLAG_THUMBNAILVIEW;    
    ofnex.lpstrFile     = new TCHAR[MAX_PATH];
    ofnex.nMaxFile      = MAX_PATH;

    bResult = GetOpenFileNameEx(&ofnex);
	
    m_strFileName= CString(ofnex.lpstrFile);
    UpdateData(FALSE);

    delete[] ofnex.lpstrFile;

}
