-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdlgversion.cpp
More file actions
126 lines (108 loc) · 3.15 KB
/
Copy pathdlgversion.cpp
File metadata and controls
126 lines (108 loc) · 3.15 KB
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
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// dlgversion.cpp
#include "misc.h"
#include "mayu.h"
#include "mayurc.h"
#include "windowstool.h"
#include "compiler_specific_func.h"
#include "layoutmanager.h"
#include <cstdio>
#include <windowsx.h>
///
class DlgVersion : public LayoutManager
{
HWND m_hwnd; ///
public:
///
DlgVersion(HWND i_hwnd)
: LayoutManager(i_hwnd),
m_hwnd(i_hwnd) {
}
/// WM_INITDIALOG
BOOL wmInitDialog(HWND /* i_focus */, LPARAM i_lParam) {
setSmallIcon(m_hwnd, IDI_ICON_mayu);
setBigIcon(m_hwnd, IDI_ICON_mayu);
wchar_t modulebuf[1024];
CHECK_TRUE( GetModuleFileName(g_hInst, modulebuf,
NUMBER_OF(modulebuf)) );
wchar_t buf[1024];
_snwprintf(buf, NUMBER_OF(buf), loadString(IDS_version).c_str(),
WIDEN(VERSION)
#ifndef NDEBUG
L" (DEBUG)"
#endif // !NDEBUG
,
loadString(IDS_homepage).c_str(),
(WIDEN(LOGNAME) L"@" + toLower(WIDEN(COMPUTERNAME))).c_str(),
WIDEN(__DATE__) L" " WIDEN(__TIME__),
getCompilerVersionString().c_str(),
modulebuf);
// _snwprintf leaves the buffer unterminated when it truncates
buf[NUMBER_OF(buf) - 1] = L'\0';
Edit_SetText(GetDlgItem(m_hwnd, IDC_EDIT_builtBy), buf);
// set layout manager
using LM = LayoutManager;
addItem(GetDlgItem(m_hwnd, IDC_STATIC_mayuIcon),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_EDIT_builtBy),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_BUTTON_download),
LM::ORIGIN_CENTER, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_CENTER, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDOK),
LM::ORIGIN_CENTER, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_CENTER, LM::ORIGIN_BOTTOM_EDGE);
restrictSmallestSize();
return TRUE;
}
/// WM_CLOSE
BOOL wmClose() {
CHECK_TRUE( EndDialog(m_hwnd, 0) );
return TRUE;
}
/// WM_COMMAND
BOOL wmCommand(int /* i_notifyCode */, int i_id, HWND /* i_hwndControl */) {
switch (i_id) {
case IDOK: {
CHECK_TRUE( EndDialog(m_hwnd, 0) );
return TRUE;
}
case IDC_BUTTON_download: {
ShellExecute(NULL, NULL, loadString(IDS_homepage).c_str(),
NULL, NULL, SW_SHOWNORMAL);
CHECK_TRUE( EndDialog(m_hwnd, 0) );
return TRUE;
}
}
return FALSE;
}
};
//
INT_PTR CALLBACK dlgVersion_dlgProc(
HWND i_hwnd, UINT i_message, WPARAM i_wParam, LPARAM i_lParam)
{
DlgVersion *wc;
getUserData(i_hwnd, &wc);
if (!wc)
switch (i_message) {
case WM_INITDIALOG:
wc = setUserData(i_hwnd, new DlgVersion(i_hwnd));
return wc->wmInitDialog(reinterpret_cast<HWND>(i_wParam), i_lParam);
}
else
switch (i_message) {
case WM_COMMAND:
return wc->wmCommand(HIWORD(i_wParam), LOWORD(i_wParam),
reinterpret_cast<HWND>(i_lParam));
case WM_CLOSE:
return wc->wmClose();
case WM_NCDESTROY:
delete wc;
return TRUE;
default:
return wc->defaultWMHandler(i_message, i_wParam, i_lParam);
}
return FALSE;
}