www.pudn.com > Winmine.zip > CustomDlg.cpp


// CustomDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "WinMine.h" 
#include "CustomDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CCustomDlg dialog 
 
 
CCustomDlg::CCustomDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CCustomDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CCustomDlg) 
	m_height = 0; 
	m_mines = 0; 
	m_width = 0; 
	//}}AFX_DATA_INIT 
} 
 
 
void CCustomDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CCustomDlg) 
	DDX_Text(pDX, IDC_HEIGHT, m_height); 
	DDX_Text(pDX, IDC_MINES, m_mines); 
	DDX_Text(pDX, IDC_WIDTH, m_width); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CCustomDlg, CDialog) 
	//{{AFX_MSG_MAP(CCustomDlg) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CCustomDlg message handlers 
 
void CCustomDlg::OnOK()  
{ 
	CDialog::OnOK(); 
	 
	if( m_width > 30 ) 
		m_width = 30; 
	if( m_height > 24 ) 
		m_height = 24; 
	int max = m_width * m_height * 4 / 5;		// 80% 
	if( m_mines > max ) 
		m_mines = max; 
}