MFC贪吃蛇完美运行


实现的界面美化,保存排名,游戏音乐播放,能正常运行,资源没BUG。
资源截图
代码片段和文件信息
// GetNameDlg.cpp : implementation file
//

#include “stdafx.h“
#include “SnakeGame.h“
#include “GetNameDlg.h“

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

/////////////////////////////////////////////////////////////////////////////
// CGetNameDlg dialog


CGetNameDlg::CGetNameDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGetNameDlg::IDD pParent)
{
//{{AFX_DATA_INIT(CGetNameDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}


void CGetNameDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGetNameDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGetNameDlg CDialog)
//{{AFX_MSG_MAP(CGetNameDlg)
ON_BN_CLICKED(IDC_ISOK OnIsok)
ON_BN_CLICKED(IDC_ISCANCLE OnIscancle)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGetNameDlg message handlers

void CGetNameDlg::OnOk()
{
return ;
}

void CGetNameDlg::OnIsok() 
{
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_NAME m_Name 20);
//  CString cs;
//  cs.Format(“%s“ m_Name);
//  MessageBox(cs);
EndDialog(IDOK);
}

char* CGetNameDlg::GetName()
{
return m_Name;
}

void CGetNameDlg::OnIscancle() 
{
// TODO: Add your control notification handler code here
EndDialog(0);
}

BOOL CGetNameDlg::OnInitDialog() 
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here

//方法一
CRect rect; 
CWnd* pWnd = AfxGetMainWnd();
//  pWnd->GetClientRect(rect);
//  pWnd->ClientToScreen(rect);
pWnd->GetWindowRect(rect);

//方法二
CRect rect2;
pWnd->GetClientRect(rect2);
pWnd->ClientToScreen(rect2);

MoveWindow(rect.left rect.top + 50 300 150);
// MoveWindow(rect2.left rect2.top 300 150);


return TRUE;  // return TRUE unless you set the focus to a control
              // EXCEPTION: OCX Property Pages should return FALSE
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-03-02 16:24  SnakeGame
     文件     1110906  2014-02-25 15:44  SnakeGameBackground.BMP
     目录           0  2014-03-02 15:42  SnakeGameDebug
     文件       13658  2014-03-02 11:10  SnakeGameDebugGetNameDlg.obj
     文件           0  2014-03-02 11:10  SnakeGameDebugGetNameDlg.sbr
     文件       18903  2014-03-02 14:04  SnakeGameDebugMainFrm.obj
     文件           0  2014-03-02 14:04  SnakeGameDebugMainFrm.sbr
     文件     4056064  2014-03-02 15:42  SnakeGameDebugSnakeGame.bsc
     文件     3813444  2014-03-02 15:43  SnakeGameDebugSnakeGame.exe
     文件      510232  2014-03-02 15:43  SnakeGameDebugSnakeGame.ilk
     文件       25786  2014-03-02 15:42  SnakeGameDebugSnakeGame.obj
     文件     6999260  2014-03-01 10:57  SnakeGameDebugSnakeGame.pch
     文件      762880  2014-03-02 15:43  SnakeGameDebugSnakeGame.pdb
     文件     2938788  2014-03-02 15:33  SnakeGameDebugSnakeGame.res
     文件           0  2014-03-02 15:42  SnakeGameDebugSnakeGame.sbr
     文件       14707  2014-03-01 10:57  SnakeGameDebugSnakeGameDoc.obj
     文件           0  2014-03-01 10:58  SnakeGameDebugSnakeGameDoc.sbr
     文件      164260  2014-03-02 15:42  SnakeGameDebugSnakeGameView.obj
     文件           0  2014-03-02 15:42  SnakeGameDebugSnakeGameView.sbr
     文件      105476  2014-03-01 10:57  SnakeGameDebugStdAfx.obj
     文件     1367639  2014-03-01 10:57  SnakeGameDebugStdAfx.sbr
     文件      246784  2014-03-02 16:17  SnakeGameDebugvc60.idb
     文件      454656  2014-03-02 15:42  SnakeGameDebugvc60.pdb
     文件       70698  2003-04-18 11:24  SnakeGameGameOver.bmp
     文件      229180  2003-04-18 17:37  SnakeGameGameOver.wav
     文件      144654  2014-03-01 15:17  SnakeGameGameOver1.bmp
     文件     2090044  2014-03-01 12:48  SnakeGameGameRest.wav
     文件        2091  2014-03-02 11:02  SnakeGameGetNameDlg.cpp
     文件        1365  2014-03-02 09:26  SnakeGameGetNameDlg.h
     文件        1924  2014-03-02 14:04  SnakeGameMainFrm.cpp
     文件        1440  2014-03-02 14:04  SnakeGameMainFrm.h
............此处省略65个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)