www.gusucode.com > 连连看游戏VC++源代码-源码程序 > 连连看游戏VC++源代码-源码程序\code\AddDlg.cpp

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

#include "stdafx.h"
#include "ZLLK.h"
#include "AddDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAddDlg dialog
extern int  g_userlevel;
extern int  g_usergate;
extern int  g_userscore;

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


void CAddDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAddDlg)
	DDX_Control(pDX, IDC_EDIT_GATE, m_gate);
	DDX_Control(pDX, IDC_EDIT_SCORE, m_score);
	DDX_Control(pDX, IDC_EDIT_LEVEL, m_level);
	DDX_Text(pDX, IDC_EDIT_NAME, m_name);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddDlg, CDialog)
	//{{AFX_MSG_MAP(CAddDlg)
	ON_COMMAND(ID_MENU_FIRST, OnMenuFirst)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddDlg message handlers

void CAddDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	//保存记录文件
	if(m_name!=_T(""))
	{
		CStdioFile mFile; 
		CFileException mExcept;
		if(!mFile.Open("user.txt",CFile::modeWrite,&mExcept))
            mFile.Open("user.txt",CFile::modeCreate|CFile::modeWrite,&mExcept);
		CString str;
		mFile.SeekToEnd();
		str.Format("%d\n",g_userscore);
		mFile.WriteString(str);
		str.Format("%s\n",m_name);
		mFile.WriteString(str);
		str.Format("%d\n",g_userlevel);
		mFile.WriteString(str);
		str.Format("%d\n",g_usergate);
		mFile.WriteString(str);	
		CDialog::OnOK();		
	}
	else AfxMessageBox("请输入姓名!");

}

BOOL CAddDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString str;
	str.Format("%d",g_usergate);
	m_gate.SetWindowText(str);
    str.Format("%d",g_userlevel);
	m_level.SetWindowText(str);
	str.Format("%d",g_userscore);
	m_score.SetWindowText(str);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddDlg::OnMenuFirst() 
{
	// TODO: Add your command handler code here
	
}