www.gusucode.com > VC++汇编语言编辑器ASMEdit源码程序 > VC++汇编语言编辑器ASMEdit源码程序\code\SetCompDlg.cpp

    // SetCompDlg.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "ASMEdit.h"
#include "SetCompDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetCompDlg dialog


CSetCompDlg::CSetCompDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetCompDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetCompDlg)
	m_CompilarCmdStr = _T("");
	m_CompilarPathStr = _T("");
	//}}AFX_DATA_INIT
}


void CSetCompDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetCompDlg)
	DDX_Text(pDX, IDC_EDIT_CompilarCmd, m_CompilarCmdStr);
	DDX_Text(pDX, IDC_EDIT_CompilarPath, m_CompilarPathStr);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetCompDlg, CDialog)
	//{{AFX_MSG_MAP(CSetCompDlg)
	ON_BN_CLICKED(IDC_BUTTON_BrowseBtn, OnBUTTONBrowseBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetCompDlg message handlers

BOOL CSetCompDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization herestd
	CStdioFile file;
	if( file.Open( "c:\\asmeditor.txt", CFile::modeRead) )
	{
		file.ReadString(m_CompilarCmdStr);
		file.ReadString(m_CompilarPathStr);
		file.Close();

		UpdateData(FALSE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetCompDlg::OnBUTTONBrowseBtn() 
{
	// TODO: Add your control notification handler code here
	static char BASED_CODE szFilter[] = "ML file (*.exe)|*.exe|All Files (*.*)|*.*||";
	CFileDialog dlg(TRUE,"exe",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter,NULL);
	if(dlg.DoModal() == IDOK)
	{
		m_CompilarPathStr = dlg.GetPathName();
		UpdateData(FALSE);
	}
}

void CSetCompDlg::OnOK() 
{
	// TODO: Add extra validation here

	UpdateData(TRUE);
	CString str = m_CompilarCmdStr + "\r\n" + m_CompilarPathStr;
	CFile l_file;
	l_file.Open("c:\\asmeditor.txt",CFile::modeCreate|CFile::modeWrite);
	l_file.Write(str,str.GetLength());
	l_file.Close();

	CDialog::OnOK();
}