Repository navigation
Expand file tree
/
Copy pathChangelogGUI.cpp
More file actions
123 lines (105 loc) · 3.7 KB
/
Copy pathChangelogGUI.cpp
File metadata and controls
123 lines (105 loc) · 3.7 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
#include "stdafx.h"
#include "ChangelogGUI.h"
ChangelogGUI ChangelogGUIObjects;
// Changelog init function
BOOL ChangelogGUI::Init()
{
ChangelogGUIObjects.wSizeX = 900;
ChangelogGUIObjects.wSizeY = 600;
ChangelogGUIObjects.szTitle.append(BrandingStringsObjects.GenericBrandingText + L" Changelog");
std::wstring windirW(MAX_PATH, 0);
UINT errWinDir = GetWindowsDirectoryW(&windirW[0], (int)windirW.size());
if (errWinDir == 0) {
MessageBoxW(nullptr, L"Failed to get path of the Windows directory", AppResStringsObjects.ErrorTitleText.c_str(), MB_ICONERROR | MB_OK);
return 1;
}
ChangelogGUIObjects.file.append(&windirW[0]);
ChangelogGUIObjects.file.append(L"\\Changelog.rtf");
return 0;
}
BOOL ChangelogGUI::Launch()
{
if (IsWindow(MainObjects.hWndRichEditCtrl))
DestroyWindow(MainObjects.hWndRichEditCtrl);
MainObjects.hWndChangelogWindow = CreateWindowExW(
WS_EX_APPWINDOW,
L"gr7Changelog",
ChangelogGUIObjects.szTitle.c_str(),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
ChangelogGUIObjects.wSizeX, ChangelogGUIObjects.wSizeY,
MainObjects.hWndMainWindow,
nullptr,
MainObjects.hInst,
nullptr
);
if (!MainObjects.hWndChangelogWindow)
{
MessageBoxW(nullptr, L"Failed to create the Changelog Window", AppResStringsObjects.ErrorTitleText.c_str(), MB_ICONERROR | MB_OK);
return 1;
}
ShowWindow(MainObjects.hWndChangelogWindow, SW_SHOW);
UpdateWindow(MainObjects.hWndChangelogWindow);
MainObjects.hWndRichEditCtrl = Grass7API::RichEditControl::CreateRichEdit(MainObjects.hWndChangelogWindow, 0, 0, ChangelogGUIObjects.wSizeX, ChangelogGUIObjects.wSizeY, MainObjects.hInst);
LONG lExStyle = GetWindowLongW(MainObjects.hWndRichEditCtrl, GWL_EXSTYLE);
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLongW(MainObjects.hWndRichEditCtrl, GWL_EXSTYLE, lExStyle);
SetWindowPos(MainObjects.hWndRichEditCtrl, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
Grass7API::RichEditControl::FillRichEditFromFile(MainObjects.hWndRichEditCtrl, ChangelogGUIObjects.file.c_str(), SF_RTF);
SendMessageW(MainObjects.hWndRichEditCtrl, EM_SETREADONLY, TRUE, 0);
return 0;
}
LRESULT CALLBACK ChangelogGUI::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int xClient; // width of client area
static int yClient; // height of client area
switch (uMsg)
{
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
lpMMI->ptMinTrackSize.x = 662;
lpMMI->ptMinTrackSize.y = 517;
}
break;
case WM_SIZE:
{
// Retrieve the dimensions of the client area.
xClient = LOWORD(lParam);
yClient = HIWORD(lParam);
SetWindowPos(MainObjects.hWndRichEditCtrl, nullptr, 0, 0, xClient, yClient, SWP_FRAMECHANGED);
}
break;
case WM_PAINT:
PAINTSTRUCT ps;
HDC hdc;
{
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
break;
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
BOOL ChangelogGUI::Register()
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = ChangelogGUI::WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = MainObjects.hInst;
wcex.hIcon = LoadIconW(MainObjects.hInst, MAKEINTRESOURCE(IDI_GR7VERSION));
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"gr7Changelog";
wcex.hIconSm = LoadIconW(wcex.hInstance, MAKEINTRESOURCE(IDI_GR7VERSION));
if (!RegisterClassExW(&wcex))
{
MessageBoxW(nullptr, L"Failed to register gr7Changelog window class", AppResStringsObjects.ErrorTitleText.c_str(), MB_ICONERROR | MB_OK);
return 1;
}
return 0;
}