加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LianliankanDlg.cpp 6.90 KB
一键复制 编辑 原始数据 按行查看 历史
Seconight 提交于 2020-07-02 11:37 . llk

// LianliankanDlg.cpp: 实现文件
//
#include "framework.h"
#include "Lianliankan.h"
#include "LianliankanDlg.h"
#include "afxdialogex.h"
#include "CGameDlg.h"
#include "CBasicGame.h"
#include "CEasyGame.h"
#include "CLevelGame.h"
#include "CRankDlg.h"
#include "CHelpDialog.h"
#include "CSettingDlg.h"
#include "global.h"
#include <mmsystem.h>
#pragma comment(lib, "WINMM.LIB")
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//extern int Setting::gameSound;
extern int iii;
extern int gameSound; //1,2
extern int gameHard; //1,2,3
extern CString userName;
extern CString gameBackground;
extern CString itemPath;
extern CString itemMask;
extern void GetIt();
extern void SetIt();
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CLianliankanDlg 对话框
CLianliankanDlg::CLianliankanDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_LIANLIANKAN_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CLianliankanDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLianliankanDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_BASIC, &CLianliankanDlg::OnClickedBtnBasic)
ON_BN_CLICKED(IDC_BTN_RELAX, &CLianliankanDlg::OnClickedBtnRelax)
ON_BN_CLICKED(IDC_BTN_RANK, &CLianliankanDlg::OnClickedBtnRank)
ON_BN_CLICKED(IDC_BTN_LEVEL, &CLianliankanDlg::OnClickedBtnLevel)
ON_BN_CLICKED(IDC_BTN_HELP, &CLianliankanDlg::OnClickedBtnHelp)
ON_BN_CLICKED(IDC_BTN_SETTING, &CLianliankanDlg::OnClickedBtnSetting)
END_MESSAGE_MAP()
// CLianliankanDlg 消息处理程序
void add(int& a) {
a = 1;
}
BOOL CLianliankanDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
//将“关于...”菜单项添加到系统菜单中。
//IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != nullptr)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
GetIt();
/*add(iii);*/
/*CString a; a.Format(_T("iii is %d"), gameSound);
MessageBox(a);*/
// TODO: 在此添加额外的初始化代码
//SetIt();
if(gameSound==1)
PlaySound(_T("D:\\Lianliankan\\aa.wav"),NULL, SND_ASYNC);
InitBackground();
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void CLianliankanDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void CLianliankanDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//创建CPaintDC对象
CPaintDC dc(this);
dc.BitBlt(0, 0, 3840, 2160, &m_dcMem, 700, 200, SRCCOPY);
////创建字体
//CFont font;
//font.CreatePointFont(200, _T("Fira Code"));
////选取字体
//CFont* oldFont;
//oldFont = dc.SelectObject(&font);
////set color
//dc.SetTextColor(RGB(0, 0, 225));
////dc.SetBkColor(RGB(0, 0, 0));
//CRect rect;
//GetClientRect(&rect);
//CString strText = _T("Come and play LLK!");
//CSize size;
//size = dc.GetTextExtent(strText, strText.GetLength());
//int x = (rect.Width() - size.cx) / 2;
//int y = (rect.Height() - size.cy) / 2;
//dc.TextOutW(x, y, strText);
CDialogEx::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CLianliankanDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CLianliankanDlg::InitBackground()
{
//加载位图
CBitmap bmpMain;
bmpMain.LoadBitmapW(IDB_MAIN_BG);
//创建兼容DC
CClientDC dc(this);
m_dcMem.CreateCompatibleDC(&dc);
m_dcMem.SelectObject(&bmpMain);
}
void CLianliankanDlg::OnClickedBtnBasic()
{
// TODO: 在此添加控件通知处理程序代码
//主界面隐藏
this->ShowWindow(SW_HIDE);
//生成game对话框
CGameDlg dlg;
FLAG current;
current.prop = false;
current.score = false;
current.timer = true;
current.sign = _T("基本模式");
dlg.m_GameC = new CBasicGame();
dlg.m_GameC->SetGameFlag(current);
dlg.DoModal();
//delete dlg;
//主界面显示
this->ShowWindow(SW_SHOW);
}
void CLianliankanDlg::OnClickedBtnRelax()
{
// TODO: 在此添加控件通知处理程序代码
this->ShowWindow(SW_HIDE);
//生成game对话框
CGameDlg dlg;
FLAG current;
current.prop = true;
current.score = true;
current.timer = false;
current.sign = _T("休闲模式");
dlg.m_GameC = new CEasyGame();
dlg.m_GameC->SetGameFlag(current);
dlg.DoModal();
//delete dlg;
//主界面显示
this->ShowWindow(SW_SHOW);
}
void CLianliankanDlg::OnClickedBtnRank()
{
// TODO: 在此添加控件通知处理程序代码
CRankDlg dlg;
dlg.DoModal();
}
void CLianliankanDlg::OnClickedBtnLevel()
{
// TODO: 在此添加控件通知处理程序代码
this->ShowWindow(SW_HIDE);
//生成game对话框
CGameDlg dlg;
FLAG current;
current.prop = true;
current.score = true;
current.timer = false;
current.sign = _T("关卡模式");
dlg.m_GameC = new CLevelGame();
/*if (dlg.m_GameC->gameMode == 3) {
MessageBox(_T("mode"));
}
if (dlg.m_GameC->currentLevel == 1) {
MessageBox(_T("level"));
}*/
dlg.m_GameC->SetGameFlag(current);
dlg.DoModal();
//delete dlg;
//主界面显示
this->ShowWindow(SW_SHOW);
}
void CLianliankanDlg::OnClickedBtnHelp()
{
// TODO: 在此添加控件通知处理程序代码
CHelpDialog dlg;
dlg.DoModal();
}
void CLianliankanDlg::OnClickedBtnSetting()
{
// TODO: 在此添加控件通知处理程序代码
CSettingDlg dlg;
dlg.DoModal();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化