1 #include "burner.h"
2 #include "version.h"
3 #include "build_details.h"
4 #include <richedit.h>
5
6 // Print text surrounded by a black outline
myDrawText(HDC hDC,RECT * pRect,TCHAR * szText,int nSizeDelta,int nColour,UINT uFormat)7 static void myDrawText(HDC hDC, RECT* pRect, TCHAR* szText, int nSizeDelta, int nColour, UINT uFormat)
8 {
9 TCHAR szName[32];
10 RECT rect;
11 HFONT hFont, myFont;
12 TEXTMETRIC myMetric;
13
14 GetTextFace(hDC, 32, szName);
15 GetTextMetrics(hDC, &myMetric);
16 myFont = CreateFont(myMetric.tmHeight + nSizeDelta, 0, 0, 0, FW_BLACK, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0, szName);
17 hFont = (HFONT)SelectObject(hDC, myFont);
18 SetBkMode(hDC, TRANSPARENT);
19
20 // Shrink the rect to allow space for the outline
21 memcpy(&rect, pRect, sizeof(RECT));
22 rect.left += 1;
23 rect.top += 1;
24 rect.right -= 1;
25 rect.bottom -= 1;
26
27 // Print the outline first
28 SetTextColor(hDC, 0);
29 rect.left -= 1;
30 rect.right -= 1;
31 DrawText(hDC, szText, -1, &rect, uFormat);
32 rect.top -= 1;
33 rect.bottom -= 1;
34 DrawText(hDC, szText, -1, &rect, uFormat);
35 rect.left += 1;
36 rect.right += 1;
37 DrawText(hDC, szText, -1, &rect, uFormat);
38 rect.left += 1;
39 rect.right += 1;
40 DrawText(hDC, szText, -1, &rect, uFormat);
41 rect.top += 1;
42 rect.bottom += 1;
43 DrawText(hDC, szText, -1, &rect, uFormat);
44 rect.top += 1;
45 rect.bottom += 1;
46 DrawText(hDC, szText, -1, &rect, uFormat);
47 rect.left -= 1;
48 rect.right -= 1;
49 DrawText(hDC, szText, -1, &rect, uFormat);
50 rect.left -= 1;
51 rect.right -= 1;
52 DrawText(hDC, szText, -1, &rect, uFormat);
53 rect.left += 1;
54 rect.right += 1;
55 rect.top -= 1;
56 rect.bottom -= 1;
57
58 // Then print the text on top
59 SetTextColor(hDC, nColour);
60 DrawText(hDC, szText, -1, &rect, uFormat);
61
62 SelectObject(hDC, hFont);
63 DeleteObject(myFont);
64 }
65
AboutDrawStrings(unsigned int nControlID,LPDRAWITEMSTRUCT pdis)66 static bool AboutDrawStrings(unsigned int nControlID, LPDRAWITEMSTRUCT pdis)
67 {
68 switch (nControlID) {
69 case IDC_FBA_VER: {
70 TCHAR szVerString[128];
71 if ((nBurnVer & 0xFFFF) > 0x9990) {
72
73 int nVer1 = ((nBurnVer >> 16) & 0xFF) + 1;
74 if ((nVer1 & 0x0F) > 9) {
75 nVer1 += 6;
76 }
77 int nVer2 = nVer1 & 0x0F;
78 nVer1 >>= 4;
79
80 _stprintf(szVerString, _T(APP_TITLE) _T(" v%s (v%i.%i Release Candidate %i)"), szAppBurnVer, nVer1, nVer2, nBurnVer & 0x0F);
81 } else {
82 if (nBurnVer & 0x00FF) {
83 _stprintf(szVerString, _T(APP_TITLE) _T(" v%s (alpha version)"), szAppBurnVer);
84 } else {
85 if (nBurnVer & 0xFF00) {
86 _stprintf(szVerString, _T(APP_TITLE) _T(" v%s (beta version)"), szAppBurnVer);
87 } else {
88 _stprintf(szVerString, _T(APP_TITLE) _T(" v%s (release version)"), szAppBurnVer);
89 }
90 }
91 }
92
93 myDrawText(pdis->hDC, &pdis->rcItem, szVerString, 2, RGB(0xFF, 0xF7, 0xDF), DT_CENTER);
94
95 return true;
96 }
97 case IDC_SPECIALSTRING: {
98
99 #ifdef SPECIALBUILD
100 TCHAR* szSpecialBuild = _T(MAKE_STRING(SPECIALBUILD));
101
102 myDrawText(pdis->hDC, &pdis->rcItem, szSpecialBuild, -1, RGB(0xFF, 0xCF, 0x7F), DT_CENTER);
103 #else
104 TCHAR szBuild[256] = _T("");
105
106 RECT rect = pdis->rcItem;
107 rect.top += 1;
108 #ifdef MMX
109 _stprintf(szBuild, _T("built on ") _T(MAKE_STRING(BUILD_DATE)) _T(", ") _T(MAKE_STRING(BUILD_TIME)) _T(" (") _T(MAKE_STRING(BUILD_CHAR)) _T(", ") _T(MAKE_STRING(BUILD_COMP)) _T(", ") _T(MAKE_STRING(BUILD_CPU)) _T("%s)"), MMX ? _T(", MMX") : _T(""));
110 #else
111 _stprintf(szBuild, _T("built on ") _T(MAKE_STRING(BUILD_DATE)) _T(", ") _T(MAKE_STRING(BUILD_TIME)) _T(" (") _T(MAKE_STRING(BUILD_CHAR)) _T(", ") _T(MAKE_STRING(BUILD_COMP)) _T(", ") _T(MAKE_STRING(BUILD_CPU)) _T("%s)"), _T(""));
112 #endif
113
114 myDrawText(pdis->hDC, &rect, szBuild, -2, RGB(0xDB, 0xDB, 0xDB), DT_CENTER);
115 #endif
116 return true;
117 }
118 }
119
120 return false;
121 }
122
123 // ----------------------------------------------------------------------------
124
AddLicenseText(HWND hDlg,unsigned int nControlID)125 void AddLicenseText(HWND hDlg, unsigned int nControlID)
126 {
127 HRSRC hrsrc = FindResource(NULL, MAKEINTRESOURCE(ID_LICENSE), MAKEINTRESOURCE(256));
128 HGLOBAL hglobal = LoadResource(NULL, hrsrc);
129 char* pszLicense = (char*)LockResource(hglobal);
130
131 SendDlgItemMessageA(hDlg, nControlID, WM_SETTEXT, (WPARAM)0, (LPARAM)pszLicense);
132 }
133
134 // ----------------------------------------------------------------------------
135
AboutProc(HWND hDlg,UINT Msg,WPARAM wParam,LPARAM lParam)136 static INT_PTR CALLBACK AboutProc(HWND hDlg ,UINT Msg, WPARAM wParam, LPARAM lParam)
137 {
138 if (Msg == WM_INITDIALOG) {
139 WndInMid(hDlg, hScrnWnd);
140 return TRUE;
141 }
142
143 if (Msg == WM_DRAWITEM) {
144 if (AboutDrawStrings(wParam, (LPDRAWITEMSTRUCT)lParam)) {
145 return TRUE;
146 }
147
148 return 0;
149 }
150
151 if (Msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SHOWLICENSE) {
152 RECT rect = { 0, 0, 0, 80 };
153
154 SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDOK), TRUE);
155 EnableWindow(GetDlgItem(hDlg, IDC_SHOWLICENSE), FALSE);
156
157 SendDlgItemMessage(hDlg, IDC_LICENSE, EM_SETMARGINS, EC_LEFTMARGIN, 3);
158 // SendDlgItemMessage(hDlg, IDC_LICENSE, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
159
160 AddLicenseText(hDlg, IDC_LICENSE);
161
162 MapDialogRect(hDlg, &rect);
163 int nSize = rect.bottom;
164 GetWindowRect(hDlg, &rect);
165 MoveWindow(hDlg, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + nSize, TRUE);
166
167 WndInMid(hDlg, hScrnWnd);
168 return 0;
169 }
170
171 if (Msg == WM_CLOSE) {
172 EndDialog(hDlg,0);
173 }
174 if (Msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK) {
175 SendMessage(hDlg, WM_CLOSE, 0, 0);
176 }
177
178 return 0;
179 }
180
AboutCreate()181 int AboutCreate()
182 {
183 HMODULE hRiched = NULL;
184
185 #if defined (_UNICODE)
186 hRiched = LoadLibrary(L"RICHED20.DLL");
187 #else
188 hRiched = LoadLibrary("RICHED20.DLL");
189 #endif
190 if (hRiched) {
191 FBADialogBox(hAppInst, MAKEINTRESOURCE(IDD_ABOUT), hScrnWnd, (DLGPROC)AboutProc);
192 FreeLibrary(hRiched);
193 hRiched = NULL;
194 }
195
196 return 0;
197 }
198
199 // ----------------------------------------------------------------------------
200
FirstProc(HWND hDlg,UINT Msg,WPARAM wParam,LPARAM lParam)201 static INT_PTR CALLBACK FirstProc(HWND hDlg ,UINT Msg, WPARAM wParam, LPARAM lParam)
202 {
203 static bool bLicenseDisplayed, bLicenseAccepted;
204
205 if (Msg == WM_INITDIALOG) {
206 TCHAR szWarningString[4096];
207
208 bLicenseDisplayed = false;
209 bLicenseAccepted = false;
210
211 SendDlgItemMessage(hDlg, IDC_LICENSE, EM_SETMARGINS, EC_LEFTMARGIN, 3);
212 // SendDlgItemMessage(hDlg, IDC_LICENSE, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
213
214 _stprintf(szWarningString, FBALoadStringEx(hAppInst, IDS_FIRSTRUN1, true), _T(APP_TITLE), szAppBurnVer);
215 _tcscat(szWarningString, FBALoadStringEx(hAppInst, IDS_FIRSTRUN2, true));
216 #if VER_ALPHA > 0 && (VER_ALPHA < 90 || VER_BETA < 99)
217 _tcscat(szWarningString, FBALoadStringEx(hAppInst, IDS_FIRSTRUN3A, true));
218 #elif VER_BETA > 0 && VER_BETA < 99
219 _tcscat(szWarningString, FBALoadStringEx(hAppInst, IDS_FIRSTRUN3B, true));
220 #endif
221
222 SendDlgItemMessage(hDlg, IDC_LICENSE, WM_SETTEXT, (WPARAM)0, (LPARAM)szWarningString);
223
224 ShowWindow(GetDlgItem(hDlg, IDC_ACCEPTLICENSE), SW_HIDE);
225
226 SetForegroundWindow(hDlg);
227 WndInMid(hDlg, NULL);
228
229 SplashDestroy(1);
230
231 return TRUE;
232 }
233
234 if (Msg == WM_DRAWITEM) {
235 if (AboutDrawStrings(wParam, (LPDRAWITEMSTRUCT)lParam)) {
236 return TRUE;
237 }
238
239 return 0;
240 }
241
242 if (Msg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK) {
243
244 if (bLicenseDisplayed) {
245 if (bLicenseAccepted) {
246 SendMessage(hDlg, WM_CLOSE, 0, 0);
247 }
248 return 0;
249 }
250
251 bLicenseDisplayed = true;
252
253 EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
254 ShowWindow(GetDlgItem(hDlg, IDC_ACCEPTLICENSE), SW_SHOW);
255 SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDC_ACCEPTLICENSE), TRUE);
256
257 AddLicenseText(hDlg, IDC_LICENSE);
258
259 return 0;
260 }
261 if (Msg == WM_COMMAND && LOWORD(wParam) == IDC_ACCEPTLICENSE) {
262 if (SendDlgItemMessage(hDlg, IDC_ACCEPTLICENSE, BM_GETSTATE, 0, 0) & BST_CHECKED) {
263 bLicenseAccepted = true;
264 EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
265 } else {
266 bLicenseAccepted = false;
267 EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
268 }
269 }
270
271 if (Msg == WM_CLOSE) {
272 if (bLicenseAccepted) {
273 EndDialog(hDlg, 0);
274 }
275 }
276
277 return 0;
278 }
279
FirstUsageCreate()280 int FirstUsageCreate()
281 {
282 HMODULE hRiched = NULL;
283
284 #if defined (_UNICODE)
285 hRiched = LoadLibrary(L"RICHED20.DLL");
286 #else
287 hRiched = LoadLibrary("RICHED20.DLL");
288 #endif
289 if (hRiched) {
290 DialogBox(hAppInst, MAKEINTRESOURCE(IDD_FIRST), hScrnWnd, (DLGPROC)FirstProc);
291 FreeLibrary(hRiched);
292 hRiched = NULL;
293 }
294
295 return 0;
296 }
297
298