// ElsGameDlg.cpp : implementation file
//*********************************************//
//吴志刚(2003-05) for Microsoft Visual C++6.0
//俄罗斯方块程序
//*********************************************//
#include "stdafx.h"
#include "ElsGame.h"
#include "ElsGameDlg.h"
#include "DlgHelp.h"
#include "DlgSetting.h"
#include "DlgSetFace.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CElsGameDlg dialog
CElsGameDlg::CElsGameDlg(CWnd* pParent /*=NULL*/)
: CDialog(CElsGameDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CElsGameDlg)
m_sumLev = _T("");
m_score = _T("");
m_hiscore = _T("");
m_slevel = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pDlgSetFace=NULL;
}
void CElsGameDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CElsGameDlg)
DDX_Control(pDX, IDC_BTNDOWN, m_BtnDown);
DDX_Control(pDX, IDC_BTNLEFT, m_BtnLeft);
DDX_Control(pDX, IDC_BTNRIGHT, m_BtnRight);
DDX_Control(pDX, IDC_BTNROTATE, m_BtnRotate);
DDX_Text(pDX, IDC_SUMLEV, m_sumLev);
DDX_Text(pDX, IDC_SCORE, m_score);
DDX_Text(pDX, IDC_HISCORE, m_hiscore);
DDX_Text(pDX, IDC_SPEEDLEVEL, m_slevel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CElsGameDlg, CDialog)
//{{AFX_MSG_MAP(CElsGameDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(IDM_EXIT, OnExit)
ON_COMMAND(IDM_START, OnStart)
ON_WM_TIMER()
ON_WM_KEYDOWN()
ON_COMMAND(IDM_ABOUT, OnAbout)
ON_COMMAND(IDM_CONTENTS, OnContents)
ON_COMMAND(IDM_PAUSE, OnPause)
ON_COMMAND(IDM_LEVEL, OnLevel)
ON_COMMAND(IDM_STOP, OnStop)
ON_COMMAND(IDM_SETFACE, OnSetface)
ON_BN_CLICKED(IDC_BTNROTATE, OnBtnrotate)
ON_BN_CLICKED(IDC_BTNLEFT, OnBtnleft)
ON_BN_CLICKED(IDC_BTNDOWN, OnBtndown)
ON_BN_CLICKED(IDC_BTNRIGHT, OnBtnright)
ON_WM_SHOWWINDOW()
ON_WM_CLOSE()
ON_WM_MOUSEMOVE()
ON_COMMAND(IDM_SAVEBMP, OnSavebmp)
ON_COMMAND(IDM_BACKGROUND, OnBackground)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CElsGameDlg message handlers
BOOL CElsGameDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
//================================================================//
//m_bSupportAlpha=FALSE;
//m_pSetLayerWindow=NULL;
//OSVERSIONINFO os;
//os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
//::GetVersionEx(&os);
//if(os.dwPlatformId == VER_PLATFORM_WIN32_NT)//WindowsNT!
//{
//HMODULE hUser32=GetModuleHandle(_T("USER32.DLL"));
//m_pSetLayerWindow=(lpfn)GetProcAddress(hUser32,_T("SetLayeredWindowAttributes"));
//if(m_pSetLayerWindow)
//{
//::SetWindowLong(*this,GWL_EXSTYLE,::GetWindowLong(*this,GWL_EXSTYLE)|WS_EX_LAYERED);
//m_nCurAlphaDegree=255;
//m_pSetLayerWindow(*this,0,m_nCurAlphaDegree,LWA_ALPHA);
//m_bSupportAlpha=TRUE;
//}
//}
//================================================================//
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
m_hIcon=LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDR_MAINFRM));
SetIcon(m_hIcon, TRUE); // Set big icon
m_hIcon=LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_MAINFRMSM));
SetIcon(m_hIcon, FALSE); // Set small icon
////////////////////////init status bar//////////////////////////////
m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM,CRect(0,0,0,0),this,102);
int iPartDim[3]={100,370,-1};
m_wndStatusBar.SetParts(2,iPartDim);
m_wndStatusBar.SetText("停止游戏",0,0);
m_wndStatusBar.SetText("方向键控制移动,空格键或上箭头控制旋转",1,0);
////////////////////////////////////////////////////////////////////////
//m_ToolBar
m_wndToolBar.CreateEx(this,TBSTYLE_FLAT,
WS_CHILD|WS_VISIBLE|CBRS_GRIPPER|CBRS_ALIGN_TOP|CBRS_TOOLTIPS,CRect(4,4,0,0));
m_wndToolBar.LoadToolBar(IDR_TOOLBAR1);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
////////////////////////按钮初始化////////////////////////
m_BtnDown.SetDirection(CTriangleButton::POINT_DOWN);
m_BtnRotate.SetDirection(CTriangleButton::POINT_UP);
m_BtnLeft.SetDirection(CTriangleButton::POINT_LEFT);
m_BtnRight.SetDirection(CTriangleButton::POINT_RIGHT);
//////////////////Clear Array Load bitmap/////////////////
CWinApp * pApp=AfxGetApp();
m_nBmpType=pApp->GetProfileInt("GAMEFACE","BLOCKTYPE",0);
m_bSameGraph=pApp->GetProfileInt("GAMEFACE","SAMEGRAPH",1);
m_bBackGround=pApp->GetProfileInt("GAMEFACE","BACKGROUND",0);
//////////////////////////////////////////////////////////
if(m_bBackGround)
{
m_strMapPath=pApp->GetProfileString("GAMEFACE","FILEPATH",NULL);
HBITMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),m_strMapPath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(bitmap)
{
CMenu* hMenu=GetMenu();
hMenu=hMenu->GetSubMenu(1);
CBitmap hBitmap;
hBitmap.Attach(bitmap);
m_brBack.CreatePatternBrush(&hBitmap);
hMenu->CheckMenuItem(IDM_BACKGROUND,MF_CHECKED);
}
else
m_bBackGround=FALSE;
}
///////////////////////////////////////////////////////////
ReLoadBitmap();
m_nCurBmpIndex=0;
InitTheArray();
m_bPlaying=FALSE;
srand(GetTickCount());
DemoStatic(rand()%7);
/////////////////////////////////////////
m_nSpeedTime=1000;
m_nSpeedLevel=0;
m_nUserSpeed=0;
/////////////////////////////////////////
m_nInitX=20;
m_nInitY=40;
m_rcGame.SetRect(m_nInitX,m_nInitY,m_nInitX+10*20,m_nInitY+19*20);
m_rcNext.SetRect(m_rcGame.right+20,m_rcGame.top,m_rcGame.right+20+80,m_rcGame.top+80);
return TRUE; // return TRUE unless you set the focus to a control
}
void CElsGameDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CElsGameDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetric
kakaxifsi
- 粉丝: 1
- 资源: 9
最新资源
- 污水监控 环境监测 云平台
- JAVA实现捡金币闯关小游戏(附源码).zip
- FPGA滤波器设计教程,教你快速设计FIR滤波器并利用IP Core实现 清单: 教程文档一份,示例代码工程一份 文档性质产品
- 视频录制和实时流OBS-Studio-30.2.3-Windows
- 农业经济学名词解释.doc
- 汽车百年发展史.doc
- 浅析幼儿园利用乡土教育资源开发园本课程内容的尝试.doc
- 热电厂锅炉试题.doc
- 三年级数学[下册]脱式计算题300题.doc
- 生物圈是最大的生态系统教学案.doc
- 上学期期末考试七年级语文试卷.doc
- 摄影基础试题-学生版[多选].doc
- 税收不安全因素管理指标+解释.doc
- 水利工程概论复习试题及答案.doc
- 统编版二年级上册语文教学计划.doc
- 污染控制微生物学试题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0