www.pudn.com > ɨÀ×Ô´Âë.rar > Mine.cpp
// Mine.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Mine.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMineApp
BEGIN_MESSAGE_MAP(CMineApp, CWinApp)
//{{AFX_MSG_MAP(CMineApp)
//}}AFX_MSG
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMineApp construction
CMineApp::CMineApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMineApp object
CMineApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMineApp initialization
BOOL CMineApp::InitInstance()
{
// Load string resources
for(int i=0; iCreateEx( 0, gcszWndClass,sResource[5],
WS_SYSMENU| WS_CAPTION |WS_MINIMIZEBOX,
uPosX, uPosY, width, height,
NULL, NULL) )
{
AfxMessageBox(sResource[9]);
return FALSE;
}
m_pMainWnd = pWnd;
RECT rect;
pWnd->GetClientRect(&rect);
uFrameWidth = width - rect.right;
uFrameHeight = height - rect.bottom;
pWnd->SetWindowSize();
pWnd->ShowWindow(SW_SHOWNORMAL);
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return TRUE;
}
int CMineApp::ExitInstance()
{
delete pWnd;
SaveGameInfo();
return CWinApp::ExitInstance();
}
BOOL CMineApp::LoadGameInfo()
{
uGameLevel = GetProfileInt(gcszSetting,gcszGameLevel,LEVEL_PRIMARY);
uCustomWidth = GetProfileInt(gcszSetting,gcszCustomWidth,PRIMARY_WIDTH);
uCustomHeight = GetProfileInt(gcszSetting,gcszCustomHeight,PRIMARY_HEIGHT);
uCustomMineNum = GetProfileInt(gcszSetting,gcszCustomMineNum,PRIMARY_MINE_NUM);
bColor = GetProfileInt(gcszSetting,gcszColor,TRUE);
bSound = GetProfileInt(gcszSetting,gcszSound,FALSE);
bMarked = GetProfileInt(gcszSetting,gcszMarked,FALSE);
uPrimaryRecord = GetProfileInt(gcszSetting,gcszPrimaryRecord,DEFAULT_RECORD);
uSecondaryRecord = GetProfileInt(gcszSetting,gcszSecondaryRecord,DEFAULT_RECORD);
uAdvancedRecord = GetProfileInt(gcszSetting,gcszAdvancedRecord,DEFAULT_RECORD);
sPrimaryRecordHolder = GetProfileString(gcszSetting,gcszPrimaryRecordHolder,sResource[1]);
sSecondaryRecordHolder = GetProfileString(gcszSetting,gcszSecondaryRecordHolder,sResource[1]);
sAdvancedRecordHolder = GetProfileString(gcszSetting,gcszAdvancedRecordHolder,sResource[1]);
return TRUE;
}
BOOL CMineApp::SaveGameInfo()
{
WriteProfileInt(gcszSetting,gcszGameLevel,uGameLevel);
WriteProfileInt(gcszSetting,gcszCustomWidth,uCustomWidth);
WriteProfileInt(gcszSetting,gcszCustomHeight,uCustomHeight);
WriteProfileInt(gcszSetting,gcszCustomMineNum,uCustomMineNum);
WriteProfileInt(gcszSetting,gcszColor,bColor);
WriteProfileInt(gcszSetting,gcszSound,bSound);
WriteProfileInt(gcszSetting,gcszMarked,bMarked);
WriteProfileInt(gcszSetting,gcszPrimaryRecord,uPrimaryRecord);
WriteProfileInt(gcszSetting,gcszSecondaryRecord,uSecondaryRecord);
WriteProfileInt(gcszSetting,gcszAdvancedRecord,uAdvancedRecord);
WriteProfileString(gcszSetting,gcszPrimaryRecordHolder,sPrimaryRecordHolder);
WriteProfileString(gcszSetting,gcszSecondaryRecordHolder,sSecondaryRecordHolder);
WriteProfileString(gcszSetting,gcszAdvancedRecordHolder,sAdvancedRecordHolder);
return TRUE;
}