-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHOMEPAGE.cpp
153 lines (124 loc) · 3.91 KB
/
CHOMEPAGE.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// CHOMEPAGE.cpp: 实现文件
//
#include "pch.h"
#include "TXZ.h"
#include "CHOMEPAGE.h"
#include "afxdialogex.h"
// CHOMEPAGE 对话框
IMPLEMENT_DYNAMIC(CHOMEPAGE, CDialogEx)
CHOMEPAGE::CHOMEPAGE(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_HOMEPAGE, pParent)
{
}
CHOMEPAGE::~CHOMEPAGE()
{
}
void CHOMEPAGE::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CHOMEPAGE, CDialogEx)
ON_BN_CLICKED(IDC_HOMEPAGE_STARTGAME, &CHOMEPAGE::OnBnClickedHomepageStartgame)
ON_BN_CLICKED(IDC_HOMEPAGE_EXITGAME, &CHOMEPAGE::OnBnClickedHomepageExitgame)
ON_BN_CLICKED(IDC_HOMEPAGE_EDITMAP, &CHOMEPAGE::OnBnClickedHomepageEditmap)
END_MESSAGE_MAP()
// CHOMEPAGE 消息处理程序
BOOL CHOMEPAGE::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
// 设置窗口
// 满屏代码
CRect ClientRect;
GetParent()->GetClientRect(ClientRect);
MoveWindow(ClientRect);
const int DIALOG_HEIGHT = ClientRect.Height();
const int DIALOG_WIDTH = ClientRect.Width();
/*
CString str;
str.Format(_T("Height is %d, Weight is %d"), DIALOG_HEIGHT, DIALOG_WIDTH);
MessageBox(str, _T("xht"));
*/
// 设置窗口按钮
/*
字体、文字大小、文字内容
按钮大小、按钮位置
焦点位置
*/
// 字体、文字大小、文字内容
m_font.CreateFont(
56, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
//FW_BOLD, // nWeight
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
//ANSI_CHARSET, // nCharSet
GB2312_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("华文琥珀")
); // lpszFac
/*
字符集:
中文用GB2312_CHARSET,或谨慎地使用DEFAULT_CHARSET
建议字体:
中文用黑体、隶书、华文琥珀、华文行楷
*/
GetDlgItem(IDC_HOMEPAGE_STARTGAME)->SetFont(&m_font);
GetDlgItem(IDC_HOMEPAGE_STARTGAME)->SetWindowText(_T("开始游戏"));
GetDlgItem(IDC_HOMEPAGE_EDITMAP)->SetFont(&m_font);
GetDlgItem(IDC_HOMEPAGE_EDITMAP)->SetWindowText(_T("编辑地图"));
GetDlgItem(IDC_HOMEPAGE_EXITGAME)->SetFont(&m_font);
GetDlgItem(IDC_HOMEPAGE_EXITGAME)->SetWindowText(_T("结束游戏"));
// 设置按钮大小、位置
const int BUTTON_HEIGHT = 120;
const int BUTTON_WIDTH = 250;
GetDlgItem(IDC_HOMEPAGE_STARTGAME)->MoveWindow((DIALOG_WIDTH - BUTTON_WIDTH) / 2, DIALOG_HEIGHT / 4 - BUTTON_HEIGHT / 2, BUTTON_WIDTH, BUTTON_HEIGHT, TRUE);
GetDlgItem(IDC_HOMEPAGE_EDITMAP)->MoveWindow((DIALOG_WIDTH - BUTTON_WIDTH) / 2, DIALOG_HEIGHT / 4 * 2 - BUTTON_HEIGHT / 2, BUTTON_WIDTH, BUTTON_HEIGHT, TRUE);
GetDlgItem(IDC_HOMEPAGE_EXITGAME)->MoveWindow((DIALOG_WIDTH - BUTTON_WIDTH) / 2, DIALOG_HEIGHT / 4 * 3 - BUTTON_HEIGHT / 2, BUTTON_WIDTH, BUTTON_HEIGHT, TRUE);
// 设置焦点
// GetDlgItem(IDC_STARTGAME)->SetFocus();
return TRUE;
//return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CHOMEPAGE::OnBnClickedHomepageStartgame()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(_T("Hello"), _T("From xht"));
GetParent()->PostMessage(WM_TOSELECTION, (WPARAM)TRUE);
}
void CHOMEPAGE::OnBnClickedHomepageExitgame()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(_T("Byebye"), _T("From xht"));
GetParent()->PostMessage(WM_CLOSE);
}
void CHOMEPAGE::OnBnClickedHomepageEditmap()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(_T("Welcome to the editor"), _T("From xht"));
GetParent()->PostMessage(WM_TOEDITOR);
}
BOOL CHOMEPAGE::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
switch (pMsg->wParam)
{
case VK_ESCAPE:
OnBnClickedHomepageExitgame();
break;
default:
return CDialogEx::PreTranslateMessage(pMsg);
}
return TRUE;
}
return CDialogEx::PreTranslateMessage(pMsg);
}