-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPauseDlg.cpp
119 lines (100 loc) · 2.48 KB
/
CPauseDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// CPauseDlg.cpp: 实现文件
//
#include "pch.h"
#include "Tetris.h"
#include "CPauseDlg.h"
#include "afxdialogex.h"
#include "CRankList.h"
#include "CGlobe.h"
// CPauseDlg 对话框
IMPLEMENT_DYNAMIC(CPauseDlg, CDialogEx)
CPauseDlg::CPauseDlg(int score, bool* exit, CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_PAUSE_DIALOG, pParent), _Score(score), _Exit(exit)
{
}
CPauseDlg::~CPauseDlg()
{
}
void CPauseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PAUSE_STATIC, _OverGame);
DDX_Control(pDX, IDC_BACK_STATIC, _Back_Button);
DDX_Control(pDX, IDC_EXIT_STATIC, _Exit_Button);
}
BEGIN_MESSAGE_MAP(CPauseDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_STN_CLICKED(IDC_BACK_STATIC, &CPauseDlg::OnStnClickedBackStatic)
ON_STN_CLICKED(IDC_EXIT_STATIC, &CPauseDlg::OnStnClickedExitStatic)
ON_WM_HELPINFO()
END_MESSAGE_MAP()
// CPauseDlg 消息处理程序
BOOL CPauseDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
_font.CreatePointFont(180, _T("Microsoft Sans Serif"));
_OverGame.SetFont(&_font);
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CPauseDlg::OnPaint()
{
CRect rect;
CPaintDC dc(this);
GetClientRect(rect);
dc.FillSolidRect(rect, RGB(53, 57, 65));
}
HBRUSH CPauseDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
auto i = pWnd->GetDlgCtrlID();
if (i == IDC_PAUSE_STATIC) {
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(230, 230, 230));
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hbr;
}
void CPauseDlg::OnStnClickedBackStatic()
{
GameSDL::ButtonDownSound();
this->OnOK();
// TODO: 在此添加控件通知处理程序代码
}
void CPauseDlg::OnStnClickedExitStatic()
{
GameSDL::ButtonDownSound();
*_Exit = true;
if (_Score == 0) {
if (Globe.dlg != NULL) {
Globe.dlg->ShowWindow(SW_SHOWNORMAL);
}
}
else {
CRankList dlg(nullptr, _Score);
dlg.DoModal();
}
this->OnOK();
}
BOOL CPauseDlg::OnHelpInfo(HELPINFO* pHelpInfo)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
return TRUE;
}
BOOL CPauseDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN) {
OnStnClickedBackStatic();
return TRUE;
}
if (pMsg->wParam == VK_ESCAPE) {
OnStnClickedBackStatic();
return TRUE;
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}