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

📄 customdlg.cpp

📁 这是一个关于扫雷游戏的代码
💻 CPP
字号:
// CustomDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Mine.h"
#include "CustomDlg.h"

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

extern CMineApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CCustomDlg dialog


CCustomDlg::CCustomDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCustomDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCustomDlg)	
	//}}AFX_DATA_INIT

	m_height = theApp.uCustomHeight;
	m_mine_num = theApp.uCustomMineNum;
	m_width = theApp.uCustomWidth;
}


void CCustomDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCustomDlg)
	DDX_Text(pDX, ID_EDIT_HEIGHT, m_height);
	DDX_Text(pDX, ID_EDIT_MINE_NUMBER, m_mine_num);
	DDX_Text(pDX, ID_EDIT_WIDTH, m_width);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCustomDlg, CDialog)
	//{{AFX_MSG_MAP(CCustomDlg)
	ON_BN_CLICKED(ID_BUTTON_SETCANCEL, OnCancel)
	ON_BN_CLICKED(ID_BUTTON_SETOK, OnOK)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCustomDlg message handlers

void CCustomDlg::OnCancel() 
{ 
	CDialog::OnCancel();
}

void CCustomDlg::OnOK() 
{  	
	CDialog::OnOK();

	if(m_width > MAX_WIDTH) 
		m_width = MAX_WIDTH;
	else if(m_width < MIN_WIDTH)  
		m_width = MIN_WIDTH;

	if( m_height > MAX_HEIGHT ) 
		m_height = MAX_HEIGHT;
	else if(m_height < MIN_HEIGHT) 
		m_height = MIN_HEIGHT;

	if(m_mine_num < MIN_MINE_NUM) 
		m_mine_num = MIN_MINE_NUM;
	
	UINT max_mines = (m_width-1)*(m_height-1);
	if( m_mine_num > max_mines ) 
		m_mine_num  = max_mines;

	theApp.uCustomWidth = m_width;
	theApp.uCustomHeight = m_height;
	theApp.uCustomMineNum = m_mine_num;
}

⌨️ 快捷键说明

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