www.pudn.com > TetrisWang.zip > ChildView.cpp


// ChildView.cpp : implementation of the CChildView class 
// 
 
#include "stdafx.h" 
#include "Tetris.h" 
#include "ChildView.h" 
#include "DlgOption.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CChildView 
 
CChildView::CChildView() 
{ 
 
} 
 
CChildView::~CChildView() 
{ 
 
} 
 
BEGIN_MESSAGE_MAP(CChildView,CWnd ) 
	//{{AFX_MSG_MAP(CChildView) 
	ON_WM_PAINT() 
	ON_WM_CREATE() 
	ON_WM_TIMER() 
	ON_WM_KEYDOWN() 
	ON_COMMAND(IDM_GAME_START, OnGameStart) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_START, OnUpdateGameStart) 
	ON_COMMAND(IDM_GAME_SINGLE, OnGameSingle) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_SINGLE, OnUpdateGameSingle) 
	ON_COMMAND(IDM_GAME_DOUBLE, OnGameDouble) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_DOUBLE, OnUpdateGameDouble) 
	ON_COMMAND(IDM_GAME_SITZKRIEG, OnGameSitzkrieg) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_SITZKRIEG, OnUpdateGameSitzkrieg) 
	ON_COMMAND(IDM_GAME_NET, OnGameNet) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_NET, OnUpdateGameNet) 
	ON_COMMAND(IDM_GAME_COMPUTER, OnGameComputer) 
	ON_UPDATE_COMMAND_UI(IDM_GAME_COMPUTER, OnUpdateGameComputer) 
	ON_WM_CLOSE() 
	ON_COMMAND(IDM_HELP_TEACH, OnHelpTeach) 
	ON_UPDATE_COMMAND_UI(IDM_HELP_TEACH, OnUpdateHelpTeach) 
	ON_COMMAND(IDM_OPTION, OnOption) 
	ON_COMMAND(IDM_OPTION_SETTING, OnOptionSetting) 
	ON_COMMAND(IDM_OPTION_CHINESE, OnOptionChinese) 
	ON_COMMAND(IDM_OPTION_ENGLISH, OnOptionEnglish) 
	ON_UPDATE_COMMAND_UI(IDM_OPTION_CHINESE, OnUpdateOptionChinese) 
	ON_UPDATE_COMMAND_UI(IDM_OPTION_ENGLISH, OnUpdateOptionEnglish) 
	ON_UPDATE_COMMAND_UI(ID_APP_EXIT, OnUpdateAppExit) 
	ON_UPDATE_COMMAND_UI(IDM_OPTION_SETTING, OnUpdateOptionSetting) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CChildView message handlers 
 
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)  
{ 
	if (!CWnd::PreCreateWindow(cs)) 
		return FALSE; 
 
	cs.dwExStyle |= WS_EX_CLIENTEDGE; 
	cs.style &= ~WS_BORDER; 
	cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,  
		::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); 
 
	return TRUE; 
} 
 
void CChildView::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
 
	for (int i=0; i0; nCell--) 
	{ 
		int x = 0; 
		int y = 0; 
 
		CBlock::SetCell(nCell); 
		for (int i=0; im_hWnd, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 
} 
 
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CWnd ::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	// TODO: Add your specialized creation code here 
	for (int i=0; iGetProfileInt("Langue", "Langue", CTetrisApp::CHINESE)); 
	CGame::SetType(m_nDefaultGameType); 
	Invalidate(); 
	return 0; 
} 
 
void CChildView::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	for (int i=0; iGetProfileInt("Difficute", "Speed1", 0); 
	m_nStartSpeed[1] = pApp->GetProfileInt("Difficute", "Speed2", 0); 
	m_nStartLines[0] = pApp->GetProfileInt("Difficute", "Lines1", 0); 
	m_nStartLines[1] = pApp->GetProfileInt("Difficute", "Lines2", 0); 
	m_nTetrisType[0] = pApp->GetProfileInt("Difficute", "TetrisType1", CGame::TETRIS_BASE); 
	m_nTetrisType[1] = pApp->GetProfileInt("Difficute", "TetrisType2", CGame::TETRIS_BASE); 
 
	m_nColorType = pApp->GetProfileInt("Display", "ColorType", 0); 
	COLORREF colDefault = RGB(51, 204, 102); 
	CString str; 
	for (int i=0; iGetProfileInt("Display", str, colDefault); 
	} 
 
	m_nComputerIntelligence = pApp->GetProfileInt("Computer", "Intelligence", 2); 
	m_bComputerFallDown = pApp->GetProfileInt("Computer", "FallDown", 1); 
 
	m_nCtrlKeys[0][0] = pApp->GetProfileInt("Operate", "Left1", VK_LEFT); 
	m_nCtrlKeys[0][1] = pApp->GetProfileInt("Operate", "Right1", VK_RIGHT); 
	m_nCtrlKeys[0][2] = pApp->GetProfileInt("Operate", "Roate1", VK_UP); 
	m_nCtrlKeys[0][3] = pApp->GetProfileInt("Operate", "Down1", VK_DOWN); 
	m_nCtrlKeys[1][0] = pApp->GetProfileInt("Operate", "Left2", 'A'); 
	m_nCtrlKeys[1][1] = pApp->GetProfileInt("Operate", "Right2", 'D'); 
	m_nCtrlKeys[1][2] = pApp->GetProfileInt("Operate", "Roate2", 'W'); 
	m_nCtrlKeys[1][3] = pApp->GetProfileInt("Operate", "Down2", 'S'); 
	m_nDefaultGameType = pApp->GetProfileInt("Operate", "GameType", 0); 
} 
 
void CChildView::SaveProfileValue(CTetrisApp* pApp) 
{ 
	pApp->WriteProfileInt("Difficute", "Speed1", m_nStartSpeed[0]); 
	pApp->WriteProfileInt("Difficute", "Speed2", m_nStartSpeed[1]); 
	pApp->WriteProfileInt("Difficute", "Lines1", m_nStartLines[0]); 
	pApp->WriteProfileInt("Difficute", "Lines2", m_nStartLines[1]); 
	pApp->WriteProfileInt("Difficute", "TetrisType1", m_nTetrisType[0]); 
	pApp->WriteProfileInt("Difficute", "TetrisType2", m_nTetrisType[1]); 
 
	pApp->WriteProfileInt("Display", "ColorType", m_nColorType); 
	CString str; 
	for (int i=0; iWriteProfileInt("Display", str, m_nColorRef[i]); 
	} 
 
	pApp->WriteProfileInt("Computer", "Intelligence", m_nComputerIntelligence); 
	pApp->WriteProfileInt("Computer", "FallDown", m_bComputerFallDown); 
 
	pApp->WriteProfileInt("Operate", "Left1", m_nCtrlKeys[0][0]); 
	pApp->WriteProfileInt("Operate", "Right1", m_nCtrlKeys[0][1]); 
	pApp->WriteProfileInt("Operate", "Roate1", m_nCtrlKeys[0][2]); 
	pApp->WriteProfileInt("Operate", "Down1", m_nCtrlKeys[0][3]); 
	pApp->WriteProfileInt("Operate", "Left2", m_nCtrlKeys[1][0]); 
	pApp->WriteProfileInt("Operate", "Right2", m_nCtrlKeys[1][1]); 
	pApp->WriteProfileInt("Operate", "Roate2", m_nCtrlKeys[1][2]); 
	pApp->WriteProfileInt("Operate", "Down2", m_nCtrlKeys[1][3]); 
	pApp->WriteProfileInt("Operate", "GameType", m_nDefaultGameType); 
} 
 
BOOL CChildView::SetDefaultValue(CTetrisApp* pApp, BOOL bReset) 
{ 
	if (!bReset) 
	{ 
		int nRunTimes = pApp->GetProfileInt("Version", "RunTimes", 0); 
		if (nRunTimes) 
		{ 
			pApp->WriteProfileInt("Version", "RunTimes", ++nRunTimes); 
			return FALSE; 
		} 
		else 
		{ 
			pApp->WriteProfileString("Version", "Write By", "Rigel(Yang-Zhan-Jin)"); 
			pApp->WriteProfileString("Version", "Version", "1.0"); 
			pApp->WriteProfileString("Version", "OverDate", "03-12-2001"); 
			pApp->WriteProfileInt("Version", "RunTimes", 1); 
			SetLangueInfo(pApp); 
		} 
	} 
 
	m_nStartSpeed[0] = 0; 
	m_nStartSpeed[1] = 0; 
	m_nStartLines[0] = 0; 
	m_nStartLines[1] = 0; 
	m_nTetrisType[0] = CGame::TETRIS_BASE; 
	m_nTetrisType[1] = CGame::TETRIS_BASE; 
 
	m_nColorType = 0; 
	m_nColorRef[0] = RGB(51, 204, 102);			// 绿	Default color, or extend block color 
	m_nColorRef[1] = RGB(200, 200, 102);		// 黄 
	m_nColorRef[2] = RGB(233, 121, 118);		// 砖红 
	m_nColorRef[3] = RGB(0, 143, 224);			// 蓝 
	m_nColorRef[4] = RGB(153, 153, 204);		// 青 
	m_nColorRef[5] = RGB(204, 204, 204);		// 灰 
	m_nColorRef[6] = RGB(232, 123,  20);		// 橙 
	m_nColorRef[7] = RGB(235,  88, 235);		// 粉 
	m_nColorRef[8] = RGB(220,  39,  75);		// 红	 
	m_nColorRef[9] = RGB(51, 204, 102);			// 绿	Default color, or extend block color 
	m_nColorRef[10] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[11] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[12] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[13] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[14] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[15] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[16] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[17] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[18] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[19] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[20] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
	m_nColorRef[21] = RGB(51, 204, 102);		// 绿	Default color, or extend block color 
 
	m_nComputerIntelligence = 2; 
	m_bComputerFallDown = 1; 
 
	m_nCtrlKeys[0][0] = VK_LEFT; 
	m_nCtrlKeys[0][1] = VK_RIGHT; 
	m_nCtrlKeys[0][2] = VK_UP; 
	m_nCtrlKeys[0][3] = VK_DOWN; 
	m_nCtrlKeys[1][0] = 'A'; 
	m_nCtrlKeys[1][1] = 'D'; 
	m_nCtrlKeys[1][2] = 'W'; 
	m_nCtrlKeys[1][3] = 'S'; 
	m_nDefaultGameType = 0; 
 
	return TRUE; 
} 
 
void CChildView::SetLangueInfo(CTetrisApp* pApp) 
{ 
	CString strChinese = CString("Langue\\Chinese"); 
	CString strEnglish = CString("Langue\\English"); 
 
	pApp->WriteProfileString(strEnglish, "AppName", "Tetris"); 
	pApp->WriteProfileString(strChinese, "AppName", "俄罗斯方块"); 
 
	pApp->WriteProfileString(strEnglish, "Next", "Next:"); 
	pApp->WriteProfileString(strChinese, "Next", "下一个:"); 
	pApp->WriteProfileString(strEnglish, "Score", "Score:"); 
	pApp->WriteProfileString(strChinese, "Score", "分数:"); 
	pApp->WriteProfileString(strEnglish, "Lines", "Lines:"); 
	pApp->WriteProfileString(strChinese, "Lines", "行数:"); 
	pApp->WriteProfileString(strEnglish, "Speed", "Speed:"); 
	pApp->WriteProfileString(strChinese, "Speed", "速度:"); 
 
	pApp->WriteProfileString(strEnglish, "GameWin", "GAME WIN"); 
	pApp->WriteProfileString(strChinese, "GameWin", "游戏获胜"); 
	pApp->WriteProfileString(strEnglish, "GameOver", "GAME OVER"); 
	pApp->WriteProfileString(strChinese, "GameOver", "游戏结束"); 
	pApp->WriteProfileString(strEnglish, "GameWait", "TETRIS"); 
	pApp->WriteProfileString(strChinese, "GameWait", "俄罗斯方块"); 
	pApp->WriteProfileString(strEnglish, "ReStart", "ReStart Game?"); 
	pApp->WriteProfileString(strChinese, "ReStart", "重新开始游戏?"); 
	 
	// 
	pApp->WriteProfileString(strEnglish, "Game", "&Game"); 
	pApp->WriteProfileString(strChinese, "Game", "游戏(&G)"); 
 
	pApp->WriteProfileString(strEnglish, "Start", "&New Game"); 
	pApp->WriteProfileString(strChinese, "Start", "开始(&N)"); 
	pApp->WriteProfileString(strEnglish, "Single", "&Single Player"); 
	pApp->WriteProfileString(strChinese, "Single", "单人游戏(&S)"); 
	pApp->WriteProfileString(strEnglish, "Double", "&Double Players"); 
	pApp->WriteProfileString(strChinese, "Double", "双人游戏(&D)"); 
	pApp->WriteProfileString(strEnglish, "Sitzkrieg", "Double Si&tzkrieg"); 
	pApp->WriteProfileString(strChinese, "Sitzkrieg", "双人对战(&T)"); 
	pApp->WriteProfileString(strEnglish, "Net", "N&et Sitzkrieg"); 
	pApp->WriteProfileString(strChinese, "Net", "网络对战(&E)"); 
	pApp->WriteProfileString(strEnglish, "Computer", "Sitzkrieg with &Computer"); 
	pApp->WriteProfileString(strChinese, "Computer", "人机对战(&C)"); 
	pApp->WriteProfileString(strEnglish, "Exit", "E&xit"); 
	pApp->WriteProfileString(strChinese, "Exit", "退出(&X)"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "&Option", "&Option"); 
	pApp->WriteProfileString(strChinese, "&Option", "选项(&O)"); 
 
	pApp->WriteProfileString(strEnglish, "Setting", "&Setting..."); 
	pApp->WriteProfileString(strChinese, "Setting", "设置(&S)..."); 
	pApp->WriteProfileString(strEnglish, "Langue", "Choose &Langue"); 
	pApp->WriteProfileString(strChinese, "Langue", "选择语言(&L)"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Help", "&Help"); 
	pApp->WriteProfileString(strChinese, "Help", "帮助(&H)"); 
 
	pApp->WriteProfileString(strEnglish, "Teach", "&Teaching"); 
	pApp->WriteProfileString(strChinese, "Teach", "教学(&T)"); 
	pApp->WriteProfileString(strEnglish, "About", "&About Tetris..."); 
	pApp->WriteProfileString(strChinese, "About", "关于俄罗斯方块(&A)..."); 
 
	pApp->WriteProfileString(strEnglish, "About Tetris", "About Tetris"); 
	pApp->WriteProfileString(strChinese, "About Tetris", "关于俄罗斯方块"); 
	pApp->WriteProfileString(strEnglish, "Version", "Tetris Version 1.0"); 
	pApp->WriteProfileString(strChinese, "Version", "俄罗斯方块 1.0 版"); 
	pApp->WriteProfileString(strEnglish, "Copyright", "Copyright (C) Rigel 2001"); 
	pApp->WriteProfileString(strChinese, "Copyright", "版权所有 (C) Rigel 2001"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Option", "Option"); 
	pApp->WriteProfileString(strChinese, "Option", "选项"); 
 
	pApp->WriteProfileString(strEnglish, "OK", "&OK"); 
	pApp->WriteProfileString(strChinese, "OK", "确定(&O)"); 
	pApp->WriteProfileString(strEnglish, "Cancel", "&Cancel"); 
	pApp->WriteProfileString(strChinese, "Cancel", "取消(&C)"); 
	pApp->WriteProfileString(strEnglish, "Save", "&Save"); 
	pApp->WriteProfileString(strChinese, "Save", "保存设置(S)"); 
	pApp->WriteProfileString(strEnglish, "Reset", "&Reset All"); 
	pApp->WriteProfileString(strChinese, "Reset", "全部重设(R)"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Computer Attrib", "Computer Attrib"); 
	pApp->WriteProfileString(strChinese, "Computer Attrib", "电脑属性"); 
	pApp->WriteProfileString(strEnglish, "Inteligence", "Inteligence:"); 
	pApp->WriteProfileString(strChinese, "Inteligence", "智能程度:"); 
	pApp->WriteProfileString(strEnglish, "FallDown", "Can Fall Down:"); 
	pApp->WriteProfileString(strChinese, "FallDown", "直接落下:"); 
	pApp->WriteProfileString(strEnglish, "Normal", "Normal"); 
	pApp->WriteProfileString(strChinese, "Normal", "一般"); 
	pApp->WriteProfileString(strEnglish, "Good", "Good"); 
	pApp->WriteProfileString(strChinese, "Good", "聪明"); 
	pApp->WriteProfileString(strEnglish, "Very Good", "Very Good"); 
	pApp->WriteProfileString(strChinese, "Very Good", "很聪明"); 
	pApp->WriteProfileString(strEnglish, "YES", "YES"); 
	pApp->WriteProfileString(strChinese, "YES", "可以"); 
	pApp->WriteProfileString(strEnglish, "NO", "NO"); 
	pApp->WriteProfileString(strChinese, "NO", "不可以"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Difficute", "Difficute"); 
	pApp->WriteProfileString(strChinese, "Difficute", "难度"); 
	pApp->WriteProfileString(strEnglish, "Start Speed", "Start Speed:"); 
	pApp->WriteProfileString(strChinese, "Start Speed", "开始速度:"); 
	pApp->WriteProfileString(strEnglish, "Start Lines", "Start Lines:"); 
	pApp->WriteProfileString(strChinese, "Start Lines", "直接落下:"); 
	pApp->WriteProfileString(strEnglish, "Tetris Type", "Tetris Type"); 
	pApp->WriteProfileString(strChinese, "Tetris Type", "方块类型"); 
	pApp->WriteProfileString(strEnglish, "Base Type", "Base Type"); 
	pApp->WriteProfileString(strChinese, "Base Type", "基本类型"); 
	pApp->WriteProfileString(strEnglish, "Extend Type", "Extend Type"); 
	pApp->WriteProfileString(strChinese, "Extend Type", "扩展类型"); 
	pApp->WriteProfileString(strEnglish, "Easy Type", "Easy Type"); 
	pApp->WriteProfileString(strChinese, "Easy Type", "简单类型"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Display", "Display"); 
	pApp->WriteProfileString(strChinese, "Display", "显示"); 
	pApp->WriteProfileString(strEnglish, "Tetris Color", "Tetris Color:"); 
	pApp->WriteProfileString(strChinese, "Tetris Color", "方块颜色:"); 
	pApp->WriteProfileString(strEnglish, "Set Tetris Color", "Set Color"); 
	pApp->WriteProfileString(strChinese, "Set Tetris Color", "设置方块颜色"); 
	pApp->WriteProfileString(strEnglish, "Set Color", "Set..."); 
	pApp->WriteProfileString(strChinese, "Set Color", "设置颜色..."); 
	pApp->WriteProfileString(strEnglish, "Own", "Use own color"); 
	pApp->WriteProfileString(strChinese, "Own", "使用各自不同颜色"); 
	pApp->WriteProfileString(strEnglish, "Same", "Use same color"); 
	pApp->WriteProfileString(strChinese, "Same", "使用同样颜色"); 
	pApp->WriteProfileString(strEnglish, "Random", "Use random color"); 
	pApp->WriteProfileString(strChinese, "Random", "使用随机颜色"); 
 
	// 
	pApp->WriteProfileString(strEnglish, "Operate", "Operate"); 
	pApp->WriteProfileString(strChinese, "Operate", "操作"); 
	pApp->WriteProfileString(strEnglish, "Roate", "Roate:"); 
	pApp->WriteProfileString(strChinese, "Roate", "旋转:"); 
	pApp->WriteProfileString(strEnglish, "Fall Down", "Fall Down:"); 
	pApp->WriteProfileString(strChinese, "Fall Down", "落下:"); 
	pApp->WriteProfileString(strEnglish, "Move Left", "Move Left:"); 
	pApp->WriteProfileString(strChinese, "Move Left", "左移:"); 
	pApp->WriteProfileString(strEnglish, "Move Right", "Move Right:"); 
	pApp->WriteProfileString(strChinese, "Move Right", "右移:"); 
	pApp->WriteProfileString(strEnglish, "Default Game Type", "Default Game Type:"); 
	pApp->WriteProfileString(strChinese, "Default Game Type", "默认游戏类型:"); 
	pApp->WriteProfileString(strEnglish, "Save Window Position", "&Save Window Position"); 
	pApp->WriteProfileString(strChinese, "Save Window Position", "保存窗口位置(&S)"); 
	pApp->WriteProfileString(strEnglish, "_Single", "Single Player"); 
	pApp->WriteProfileString(strChinese, "_Single", "单人游戏"); 
	pApp->WriteProfileString(strEnglish, "_Double", "Double Players"); 
	pApp->WriteProfileString(strChinese, "_Double", "双人游戏"); 
	pApp->WriteProfileString(strEnglish, "_Sitzkrieg", "Double Sitzkrieg"); 
	pApp->WriteProfileString(strChinese, "_Sitzkrieg", "双人对战"); 
	pApp->WriteProfileString(strEnglish, "_Net", "Net Sitzkrieg"); 
	pApp->WriteProfileString(strChinese, "_Net", "网络对战"); 
	pApp->WriteProfileString(strEnglish, "_Computer", "Sitzkrieg with Computer"); 
	pApp->WriteProfileString(strChinese, "_Computer", "人机对战"); 
 
	pApp->WriteProfileString(strEnglish, "Set Key", "Set Key"); 
	pApp->WriteProfileString(strChinese, "Set Key", "设置键"); 
	pApp->WriteProfileString(strEnglish, "Select Key", "Please select a Key"); 
	pApp->WriteProfileString(strChinese, "Select Key", "请选择一个键"); 
	pApp->WriteProfileString(strEnglish, "Key Used", "The KEY has been defined, please choose another."); 
	pApp->WriteProfileString(strChinese, "Key Used", "所选键已定义,请选择其它键。"); 
 
	pApp->WriteProfileString(strEnglish, "Player1", "PlayerI"); 
	pApp->WriteProfileString(strChinese, "Player1", "玩家I"); 
	pApp->WriteProfileString(strEnglish, "Player2", "PlayerII"); 
	pApp->WriteProfileString(strChinese, "Player2", "玩家II"); 
 
} 
 
void CChildView::GameAddLines(int nIndex, int nLines) 
{ 
	int nGame; 
	if (nIndex == 1) 
		nGame = 0; 
	else if (nIndex == 0) 
		nGame = 1; 
	else 
		return; 
	m_Games[nGame].AddLines(nLines); 
} 
 
void CChildView::GameWin(int nIndex) 
{ 
	int nGame; 
	if (nIndex == 1) 
		nGame = 0; 
	else if (nIndex == 0) 
		nGame = 1; 
	else 
		return; 
	if (m_Games[nGame].GetStatus() == CGame::STATUS_RUN) 
	{ 
		m_Games[nGame].SetWin(); 
		m_Games[nGame].EndGame(); 
	} 
} 
 
void CChildView::OnGameStart()  
{ 
	// TODO: Add your command handler code here 
	int i; 
	BOOL bCheckReStart = FALSE; 
	for (i=0; iSetText(GetLangueString("Start")); 
} 
 
void CChildView::OnGameSingle()  
{ 
	// TODO: Add your command handler code here 
	CGame::SetType(CGame::TYPE_SINGLE); 
	OnGameStart(); 
} 
 
void CChildView::OnUpdateGameSingle(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_SINGLE); 
	pCmdUI->SetText(GetLangueString("Single")); 
} 
 
void CChildView::OnGameDouble()  
{ 
	// TODO: Add your command handler code here 
	CGame::SetType(CGame::TYPE_DOUBLE); 
	OnGameStart(); 
} 
 
void CChildView::OnUpdateGameDouble(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_DOUBLE); 
	pCmdUI->SetText(GetLangueString("Double")); 
} 
 
void CChildView::OnGameSitzkrieg()  
{ 
	// TODO: Add your command handler code here 
	CGame::SetType(CGame::TYPE_SITZKRIEG); 
	OnGameStart(); 
} 
 
void CChildView::OnUpdateGameSitzkrieg(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_SITZKRIEG); 
	pCmdUI->SetText(GetLangueString("Sitzkrieg")); 
} 
 
void CChildView::OnGameNet()  
{ 
	// TODO: Add your command handler code here 
	CGame::SetType(CGame::TYPE_NET); 
	OnGameStart(); 
} 
 
void CChildView::OnUpdateGameNet(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_NET); 
	pCmdUI->SetText(GetLangueString("Net")); 
} 
 
void CChildView::OnGameComputer()  
{ 
	// TODO: Add your command handler code here 
	CGame::SetType(CGame::TYPE_COMPUTER); 
	OnGameStart(); 
} 
 
void CChildView::OnUpdateGameComputer(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_COMPUTER); 
	pCmdUI->SetText(GetLangueString("Computer")); 
} 
 
void CChildView::OnClose()  
{ 
	// TODO: Add your message handler code here and/or call default 
	for (int i=0; iGetProfileInt("Operate", "SavePos", 0)) 
//	{ 
		CRect rect; 
		::GetWindowRect(AfxGetApp()->m_pMainWnd->m_hWnd, &rect); 
		AfxGetApp()->WriteProfileInt("Operate", "XPos", rect.left); 
		AfxGetApp()->WriteProfileInt("Operate", "YPos", rect.top); 
//	} 
	CWnd ::OnClose(); 
} 
 
void CChildView::OnHelpTeach()  
{ 
	// TODO: Add your command handler code here 
	bool bTeach = CGame::GetType() == CGame::TYPE_TEACH; 
	if (bTeach) 
	{ 
		CGame::SetType(m_nLastGameType); 
		m_Games[0].EndGame(); 
		m_Games[0].SetStatus(CGame::STATUS_WAIT); 
		Invalidate(); 
	} 
	else 
	{ 
		m_nLastGameType = CGame::GetType(); 
		CGame::SetType(CGame::TYPE_TEACH); 
		OnGameStart(); 
	} 
} 
 
void CChildView::OnUpdateHelpTeach(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CGame::GetType() == CGame::TYPE_TEACH); 
	pCmdUI->SetText(GetLangueString("Teach")); 
} 
 
void CChildView::OnOption()  
{ 
	// TODO: Add your command handler code here 
} 
 
void CChildView::OnOptionSetting()  
{ 
	// TODO: Add your command handler code here 
	CDlgOption dlgOption(this); 
	dlgOption.DoModal(); 
} 
 
void CChildView::OnUpdateOptionSetting(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetText(GetLangueString("Setting")); 
} 
 
void CChildView::OnOptionChinese()  
{ 
	// TODO: Add your command handler code here 
	if (CTetrisApp::m_nLangue == CTetrisApp::CHINESE) return; 
	LangueChange(CTetrisApp::CHINESE); 
	Invalidate(); 
} 
 
void CChildView::OnOptionEnglish()  
{ 
	// TODO: Add your command handler code here 
	if (CTetrisApp::m_nLangue == CTetrisApp::ENGLISH) return; 
	LangueChange(CTetrisApp::ENGLISH); 
	Invalidate(); 
} 
 
void CChildView::OnUpdateOptionChinese(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CTetrisApp::m_nLangue == CTetrisApp::CHINESE); 
} 
 
void CChildView::OnUpdateOptionEnglish(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(CTetrisApp::m_nLangue == CTetrisApp::ENGLISH); 
} 
 
void CChildView::OnUpdateAppExit(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetText(GetLangueString("Exit")); 
}