⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 herodlg.cpp

📁 射击小游戏
💻 CPP
字号:
// HeroDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Shoot.h"
#include "HeroDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHeroDlg dialog


CHeroDlg::CHeroDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHeroDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHeroDlg)
	m_strName = _T("");
	m_iScore =0;
	m_iLastScore = 0;
	m_strLastName = _T("");
	//}}AFX_DATA_INIT
}


void CHeroDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHeroDlg)
	DDX_Text(pDX, IDC_NAME, m_strName);
	DDX_Text(pDX, IDC_SCORE, m_iScore);
//	DDV_MinMaxInt(pDX, m_iScore, 0, 20);
	DDX_Text(pDX, IDC_LASTSCORE, m_iLastScore);
	DDX_Text(pDX, IDC_LASTNAME, m_strLastName);
	//}}AFX_DATA_MAP
}
void CHeroDlg::SetScore(int s)
{
	m_iScore = s;
//	UpdateData();
}

BEGIN_MESSAGE_MAP(CHeroDlg, CDialog)
	//{{AFX_MSG_MAP(CHeroDlg)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHeroDlg message handlers

void CHeroDlg::SetLastScore(int score)
{
	m_iLastScore = score;
//	UpdateData();
}

void CHeroDlg::SetLastName(CString str)
{
	m_strLastName = str;
//	UpdateData();
}
//此函数负责确认用户输入,把数据保存到外部文件中
void CHeroDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	fstream file("text.txt",ios::out|ios::binary);
	file<<m_iScore;
	file<<(LPCTSTR)m_strName;
	CDialog::OnOK();
}

int CHeroDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -