// LoadObjectDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mapeditor.h"
#include "LoadObjectDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLoadObjectDlg dialog


CLoadObjectDlg::CLoadObjectDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLoadObjectDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLoadObjectDlg)
	m_szFileName = _T("");
	//}}AFX_DATA_INIT
}


void CLoadObjectDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLoadObjectDlg)
	DDX_Text(pDX, IDC_EDIT_FILE_NAME, m_szFileName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLoadObjectDlg, CDialog)
	//{{AFX_MSG_MAP(CLoadObjectDlg)
	ON_BN_CLICKED(IDC_BUTTON_LOAD_FILE, OnButtonLoadFile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLoadObjectDlg message handlers

void CLoadObjectDlg::OnButtonLoadFile() 
{
	CFileDialog dlg(TRUE,"x",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT , "x Files (*.x)|*.x||", NULL);
	if(dlg.DoModal() == IDOK)
	{
		POSITION pos = dlg.GetStartPosition();
		const char* pdest;
		CString str;
		while(pos)
		{
			CString strPath = dlg.GetNextPathName( pos );

			pdest = strrchr( (LPCTSTR)strPath, '\\' );
			str = pdest+1;
		}
		m_szFileName = str;
		UpdateData( FALSE );
	}
}
