-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDlgAbout.cpp
288 lines (238 loc) · 7.52 KB
/
DlgAbout.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// DlgAbout.cpp : implementation file
//
#include "stdafx.h"
#include <mmsystem.h>
#include "thhyl.h"
#include "DlgAbout.h"
#include "global.h"
#include "indep/OSVer.h"
#pragma comment (lib, "winmm.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static BOOL yinxiao = FALSE;
static int yinxiao_count = 0;
static LPCTSTR myemail = _T("wingzero1040@gmail.com");
static LPCTSTR updateurl = _T("https://www.zybuluo.com/wz520/note/15842");
/////////////////////////////////////////////////////////////////////////////
// CDlgAbout dialog
CDlgAbout::CDlgAbout(CWnd* pParent /*=NULL*/)
: CDlgBaseWZ(CDlgAbout::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgAbout)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_dlgopt |= DLGWZ_OPT_NOCHANGECOUNT;
}
void CDlgAbout::DoDataExchange(CDataExchange* pDX)
{
CDlgBaseWZ::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgAbout)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgAbout, CDlgBaseWZ)
//{{AFX_MSG_MAP(CDlgAbout)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_MYEMAIL, OnMyemail)
ON_BN_CLICKED(IDC_UPDATEURL, OnUpdateurl)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_ABOUTPIC, OnAboutpic)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgAbout message handlers
void CDlgAbout::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDlgBaseWZ::OnLButtonDown(nFlags, point);
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
}
static BOOL IsWow64()
{
BOOL bIsWow64 = FALSE;
//IsWow64Process is not available on all supported versions of Windows.
//Use GetModuleHandle to get a handle to the DLL that contains the function
//and GetProcAddress to get a pointer to the function if available.
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
if (NULL != fnIsWow64Process) {
fnIsWow64Process(GetCurrentProcess(),&bIsWow64);
}
return bIsWow64;
}
// calc count of bit 1, using Hamming Weight
static DWORD calcbit1count(DWORD n)
{
n = (n&0x55555555) + ((n>>1)&0x55555555);
n = (n&0x33333333) + ((n>>2)&0x33333333);
n = (n&0x0f0f0f0f) + ((n>>4)&0x0f0f0f0f);
n = (n&0x00ff00ff) + ((n>>8)&0x00ff00ff);
return (n&0x0000ffff) + ((n>>16)&0x0000ffff);
}
static DWORD GetCPUCount()
{
DWORD_PTR procmask=0, sysmask=0;
GetProcessAffinityMask(GetCurrentProcess(), &procmask, &sysmask);
return calcbit1count(sysmask);
}
BOOL CDlgAbout::OnInitDialog()
{
CDlgBaseWZ::OnInitDialog();
// TODO: Add extra initialization here
m_dlgopt |= DLGWZ_OPT_ALWAYSANYDRAG;
m_tooltip.AddTool( GetDlgItem(IDC_UPDATEURL), updateurl );
m_tooltip.AddTool( GetDlgItem(IDC_MYEMAIL), myemail );
CEdit* const pEdit = (CEdit*)GetDlgItem(IDC_EDITABOUT);
CString abt;
const DWORD pid = GetCurrentProcessId();
const DWORD tid = GetCurrentThreadId();
const DWORD tickcount = GetTickCount();
abt.Format(
_T("%s %d.%02d\r\n\r\n")
_T("Written by %c%c%u\r\n")
_T("贴吧ID: 天使的枷锁\r\n")
_T("邮箱: %s\r\n\r\n")
_T("更新地址:\r\n%s\r\nhttps://pan.baidu.com/s/1pKRLyTd (码:f928)\r\n\r\n")
_T("-----------------------------------------------\r\n")
_T("操作系统: Windows %s %s %s\r\n")
_T("处理器数量: %lu\r\n")
_T("当前进程 PID: %lu(0x%lx)\r\n")
_T("当前线程 TID: %lu(0x%lx)\r\n")
_T("GetTickCount(): %lu(0x%lx)\r\n")
, g_title, 1, 87
, _T('w'), _T('z'), 520
, myemail
, updateurl
, OSVerGetOSString(), (IsWow64() ? _T("64位") : _T("32位")), OSVerGetCSDVersion()
, GetCPUCount()
, pid, pid
, tid, tid
, tickcount, tickcount
);
pEdit->SetWindowText(abt);
// yinxiao
static bool firstcall = true;
yinxiao_count = 0;
if ( !firstcall ) {
CButton* const pButton = (CButton*)GetDlgItem(IDOK);
VERIFY(pButton->ModifyStyle( 0, BS_ICON, 0 ));
pButton->SetIcon( ::LoadIcon( ::GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_YINSMILE) ) );
VERIFY(pButton->ModifyStyle( BS_DEFPUSHBUTTON | WS_TABSTOP, 0, 0 ));
// this->GetNextDlgTabItem(pButton)->SetFocus();
(CButton*)GetDlgItem(IDC_MYEMAIL)->SetFocus();
yinxiao = TRUE;
}
else {
firstcall = false;
yinxiao = FALSE;
}
this->CenterWindow();
return !yinxiao; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgAbout::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (yinxiao) {
CButton* const pButton = (CButton*)GetDlgItem(IDOK);
RECT winrect, rect;
this->GetClientRect(&winrect);
pButton->GetWindowRect(&rect);
this->ScreenToClient(&rect);
TRACE(_T("winrect=%d,%d,%d,%d; rect=%d,%d,%d,%d; mouse=%d,%d"),
winrect.left, winrect.top, winrect.right, winrect.bottom,
rect.left, rect.top, rect.right, rect.bottom,
point.x, point.y
);
if (rect.bottom < 200 && point.y < rect.bottom + 50) {
pButton->MoveWindow(rect.left, rect.top + 180, rect.right-rect.left, rect.bottom - rect.top);
++yinxiao_count;
}
else if (rect.bottom > 200 && point.y > rect.top - 50) {
pButton->MoveWindow(rect.left, rect.top - 180, rect.right-rect.left, rect.bottom - rect.top);
++yinxiao_count;
}
if (yinxiao_count == 20) {
CEdit* const pEdit = (CEdit*)GetDlgItem(IDC_EDITABOUT);
pEdit->SetWindowText(_T("鼠标娘要被你磨坏了。还是按 ESC 键吧 =v="));
}
}
CDlgBaseWZ::OnMouseMove(nFlags, point);
}
void CDlgAbout::OnMyemail()
{
// TODO: Add your control notification handler code here
ShellExecute(NULL, _T("open"), CString("mailto:") + myemail, NULL, NULL, SW_SHOWDEFAULT);
}
void CDlgAbout::OnUpdateurl()
{
// TODO: Add your control notification handler code here
ShellExecute(NULL, _T("open"), updateurl, NULL, NULL, SW_SHOWDEFAULT);
}
void CDlgAbout::OnOK()
{
// TODO: Add extra validation here
if (yinxiao) {
CButton* const pButton = (CButton*)GetDlgItem(IDOK);
CPoint pt;
CRect rect;
GetCursorPos(&pt);
pButton->GetWindowRect(&rect);
if (rect.PtInRect(pt)) {
PlaySound(MAKEINTRESOURCE(IDR_PLDEAD00), ::GetModuleHandle(NULL), SND_ASYNC | SND_RESOURCE);
}
}
OnCancel();
}
void CDlgAbout::OnCancel()
{
DestroyWindow();
}
HBRUSH CDlgAbout::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDlgBaseWZ::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch (nCtlColor)
{
case CTLCOLOR_DLG:
{
static HBRUSH bkhbr = NULL;
if (bkhbr != NULL)
DeleteObject(bkhbr); // delete old brush
COLORREF bkcolor = (simple_random() & 0xffffff) | 0x808080;
bkhbr = CreateSolidBrush(bkcolor);
hbr = bkhbr;
}
break;
case CTLCOLOR_STATIC:
{
static HBRUSH bkhbr = NULL;
if (bkhbr != NULL)
DeleteObject(bkhbr); // delete old brush
COLORREF bkcolor = (simple_random() & 0xffffff) | 0x808080;
pDC->SetBkColor(bkcolor);
pDC->SetTextColor(0x000000); // force black
bkhbr = CreateSolidBrush(bkcolor);
hbr = bkhbr;
}
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CDlgAbout::OnAboutpic()
{
// TODO: Add your control notification handler code here
CStatic* const pPic = (CStatic*)GetDlgItem(IDC_ABOUTPIC);
HICON const hMarisa = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
bool const isMarisa = pPic->GetIcon() == hMarisa;
if (isMarisa)
pPic->SetIcon( AfxGetApp()->LoadIcon(IDI_REIMU) );
else
pPic->SetIcon( hMarisa );
}