/***************************************************************************
**
**    $Header:   D:/EP196/SRC/LOG/SRCDLL/SRCLOAD.CPP   1.0   15 Aug 1997 14:03:38   ZJRD  $
**
**    $Log:   D:/EP196/SRC/LOG/SRCDLL/SRCLOAD.CPP  $
** 
**    Rev 1.0   15 Aug 1997 14:03:38   ZJRD
** Initial revision.
** 
**    Rev 1.1.7.0   19 Jun 1997 14:49:06   ZJRD
** 1.0c
** 
****************************************************************************/

// srcload.cpp : implementation file
//

#include "stdafx.h"
#include "srcdll.h"
#include "srcload.h"
#include "srcsht.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSourceLoadDlg dialog

CSourceLoadDlg::CSourceLoadDlg(BOOL bOpenFileDialog, 
				   LPCSTR lpszDefExt,
				   LPCSTR lpszFileName, 
				   DWORD dwFlags, 
				   LPCSTR lpszFilter, 
				   CWnd* pParentWnd)
	: CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
{
	//{{AFX_DATA_INIT(CSourceLoadDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	
	// Initialize OPENFILENAME
//	m_ofn.hInstance = AfxGetInstanceHandle();
	m_ofn.hInstance = AfxFindResourceHandle(MAKEINTRESOURCE(IDD), RT_DIALOG);
	m_ofn.Flags |= OFN_ENABLETEMPLATE;
	m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD);
	SetHelpID(IDD);
	m_strDefFile = lpszFileName;
	if (!m_strDefFile.IsEmpty()) m_strDefFile.MakeLower();
}

void CSourceLoadDlg::DoDataExchange(CDataExchange* pDX)
{
	CFileDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSourceLoadDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSourceLoadDlg, CFileDialog)
	//{{AFX_MSG_MAP(CSourceLoadDlg)
	ON_BN_CLICKED(ID_LOAD_OPTION, OnLoadOption)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CSourceLoadDlg message handlers

void CSourceLoadDlg::OnLoadOption() 
{
	// TODO: Add your control notification handler code here

	// Open LoadOption page
	CSourceSheet sheet(this, CSourceSheet::pageLoadOption);
	sheet.DoModal();
}


BOOL CSourceLoadDlg::OnInitDialog()
{                                  
	BOOL b = CFileDialog::OnInitDialog();
	
	if ( ((CComboBox*)GetDlgItem(1136)) ) 
	{   
		int nSel = 0;
		if (m_strDefFile.IsEmpty() || m_strDefFile.Find("*.abs") != -1)
			nSel = 0;
		else if (m_strDefFile.Find("*.d32") != -1)
			nSel = 1;
		else if (m_strDefFile.Find("*.hex") != -1)
			nSel = 2;
		else nSel = 3;
		
		((CComboBox*)GetDlgItem(1136))->SetCurSel(nSel);
	}
		
	return b;		
}