forked from AndyWhittaker/FreeScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
About.cpp
466 lines (395 loc) · 12.3 KB
/
About.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
// About.cpp : implementation file
//
// (c) 1996-99 Andy Whittaker, Chester, England.
// mail@andywhittaker.com
//
#include "About.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#define SCROLLAMOUNT -1
#define DISPLAY_SLOW 70
#define DISPLAY_MEDIUM 40
#define DISPLAY_FAST 20
#define DISPLAY_SPEED DISPLAY_FAST
#define RED RGB(255,0,0)
#define GREEN RGB(0,255,0)
#define BLUE RGB(0,0,255)
#define WHITE RGB(255,255,255)
#define YELLOW RGB(255,255,0)
#define TURQUOISE RGB(0,128,255)
#define PURPLE RGB(255,0,255)
#define BLACK RGB(0,0,0)
#define BACKGROUND_COLOR BLACK
#define TOP_LEVEL_TITLE_COLOR RED
#define TOP_LEVEL_GROUP_COLOR YELLOW
#define GROUP_TITLE_COLOR TURQUOISE
#define NORMAL_TEXT_COLOR WHITE
// You can set font heights here to suit your taste
#define TOP_LEVEL_TITLE_HEIGHT 21
#define TOP_LEVEL_GROUP_HEIGHT 19
#define GROUP_TITLE_HEIGHT 17
#define NORMAL_TEXT_HEIGHT 15
// these define the escape sequences to suffix each array line with. They
// are listed in order of descending font size.
#define TOP_LEVEL_TITLE '\n'
#define TOP_LEVEL_GROUP '\r'
#define GROUP_TITLE '\t'
#define NORMAL_TEXT '\f'
#define DISPLAY_BITMAP '\b'
// Enter the text and bitmap resource string identifiers which are to
// appear in the scrolling list. Append each non-empty string entry with
// an escape character corresponding to the desired font effect. Empty
// strings do not get a font assignment.
// (see #defines above)
//
// Array count. Make sure this keeps up with how many lines there are
// in the array!
#define ARRAYCOUNT 63
char *pArrCredit[] = { "LOGO\b",
"look into your Engine Management System with your PC \f",
"",
"Copyright (c) 1999-2012 Andy Whittaker - Macclesfield, UK, mail@andywhittaker.com \f",
"All Rights Reserved \f",
"",
"",
"Programming, User Interface and Conception \t",
"Andy Whittaker \f",
"",
"Documentation \t",
"Soon, at a price! \f",
"",
"",
"PROTOCOLS\b",
"ELM327 \t",
"Andy Whittaker \f",
"",
"Lotus Esprit \t",
"Andy Whittaker \f",
"",
"Lotus Elan \t",
"Ian Levy \f",
"",
"Lotus Carlton \t",
"Malcolm Robb \f",
"",
"GM 1994 Camaro Z28 \t",
"Andrew Mattei \f",
"Testing by Dale Klein \f",
"",
"GM 1992-3 Camaro Z28 \t",
"B Henson and Andrew Mattei \f",
"",
"GM 1992 Pontiac \t",
"Bob Currey and B Henson \f",
"",
"GM 1989 Chevrolet Corvette \t",
"Andrew Mattei \f",
"",
"GM 160 Protocol \t",
"Testing by Moe Whittlemore \f",
"",
"",
"SPECIALTHANKS\b",
"ToolTip Class \t",
"Dundas Software: http://www.dundas.com/ \f",
"",
"Communications Class \t",
"Remon Spekreijse, et al \f",
"",
"Scrolling Credits \t",
"Mark Findlay \f",
"",
"HyperLink Class \t",
"Chris Maunder, et al \f",
"",
"",
"NOTFORGETTING\b",
"http://www.codeguru.com/ \f",
"",
"http://www.naughter.com/ \f",
"",
"",
""
};
/////////////////////////////////////////////////////////////////////////////
// CAbout property page
IMPLEMENT_DYNCREATE(CAbout, CPropertyPage)
CAbout::CAbout() : CPropertyPage(CAbout::IDD)
{
//{{AFX_DATA_INIT(CAbout)
//}}AFX_DATA_INIT
}
CAbout::~CAbout()
{
}
void CAbout::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAbout)
DDX_Control(pDX, IDC_HYPERLINK, m_HyperLink1);
DDX_Control(pDX, IDC_HYPERLINK2, m_HyperLink2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAbout, CPropertyPage)
//{{AFX_MSG_MAP(CAbout)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_DESTROY()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
ON_STN_CLICKED(IDC_HYPERLINK2, &CAbout::OnStnClickedHyperlink2)
END_MESSAGE_MAP()
//************************************************************************
// OnPaint
//
// Send the newly updated work string to the display rect.
//************************************************************************
void CAbout::OnPaint()
{
CPaintDC dc(this); // device context for painting
PAINTSTRUCT ps;
CDC* pDc = m_pDisplayFrame->BeginPaint(&ps);
pDc->SetBkMode(TRANSPARENT);
//*********************************************************************
// FONT SELECTION
CFont m_fntArial;
CFont* pOldFont = NULL;
BOOL bSuccess;
BOOL bUnderline;
BOOL bItalic;
if (!m_szWork.IsEmpty())
switch (m_szWork[m_szWork.GetLength()-1] )
{
case NORMAL_TEXT:
default:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
bSuccess = m_fntArial.CreateFont(NORMAL_TEXT_HEIGHT, 0, 0, 0,
FW_THIN, (BYTE) bItalic, (BYTE) bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(NORMAL_TEXT_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case TOP_LEVEL_GROUP:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = TOP_LEVEL_GROUP_HEIGHT;
bSuccess = m_fntArial.CreateFont(TOP_LEVEL_GROUP_HEIGHT, 0, 0, 0,
FW_BOLD, (BYTE) bItalic, (BYTE) bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(TOP_LEVEL_GROUP_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case GROUP_TITLE:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = GROUP_TITLE_HEIGHT;
bSuccess = m_fntArial.CreateFont(GROUP_TITLE_HEIGHT, 0, 0, 0,
FW_BOLD, (BYTE) bItalic, (BYTE) bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(GROUP_TITLE_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case TOP_LEVEL_TITLE:
bItalic = FALSE;
bUnderline = TRUE;
nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0,
FW_BOLD, (BYTE) bItalic, (BYTE) bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case DISPLAY_BITMAP:
if (!m_bProcessingBitmap)
{
CString szBitmap = m_szWork.Left(m_szWork.GetLength()-1);
if (!m_bmpWork.LoadBitmap((const char *)szBitmap))
{
CString str;
str.Format("Could not find bitmap resource \"%s\". "
"Be sure to assign the bitmap a QUOTED resource name", szBitmap.GetString());
KillTimer(DISPLAY_TIMER_ID);
MessageBox(str);
return;
}
m_bmpCurrent = &m_bmpWork;
m_bmpCurrent->GetObject(sizeof(BITMAP), &m_bmpInfo);
m_size.cx = m_bmpInfo.bmWidth; // width of dest rect
RECT workRect;
m_pDisplayFrame->GetClientRect(&workRect);
m_pDisplayFrame->ClientToScreen(&workRect);
ScreenToClient(&workRect);
// upper left point of dest
m_pt.x = (workRect.right -
((workRect.right-workRect.left)/2) - (m_bmpInfo.bmWidth/2));
m_pt.y = workRect.bottom;
pBmpOld = m_dcMem.SelectObject(m_bmpCurrent);
if (m_hBmpOld == 0)
m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle();
m_bProcessingBitmap = TRUE;
}
break;
}
CBrush bBrush(BACKGROUND_COLOR);
CBrush* pOldBrush;
pOldBrush = pDc->SelectObject(&bBrush);
// Only fill rect comprised of gap left by bottom of scrolling window
r=m_ScrollRect;
r.top = r.bottom-abs(SCROLLAMOUNT);
pDc->DPtoLP(&r);
if (m_bFirstTime)
{
m_bFirstTime=FALSE;
pDc->FillRect(&m_ScrollRect,&bBrush);
}
else
pDc->FillRect(&r,&bBrush);
r=m_ScrollRect;
r.top = r.bottom-nClip;
if (!m_bProcessingBitmap)
{
pDc->DrawText((const char *)m_szWork,m_szWork.GetLength()-1,&r,DT_TOP|DT_CENTER|
DT_NOPREFIX | DT_SINGLELINE);
m_bDrawText=FALSE;
}
else
{
dc.StretchBlt( m_pt.x, m_pt.y-nClip, m_size.cx, nClip,
&m_dcMem, 0, 0, m_bmpInfo.bmWidth-1, nClip,
SRCCOPY );
if (nClip > m_bmpInfo.bmHeight)
{
m_bmpWork.DeleteObject();
m_bProcessingBitmap = FALSE;
nClip=0;
m_szWork.Empty();
nCounter=1;
}
pDc->SelectObject(pOldBrush);
bBrush.DeleteObject();
m_pDisplayFrame->EndPaint(&ps);
return;
}
pDc->SelectObject(pOldBrush);
bBrush.DeleteObject();
if (!m_szWork.IsEmpty())
{
pDc->SelectObject(pOldFont);
m_fntArial.DeleteObject();
}
m_pDisplayFrame->EndPaint(&ps);
// Do not call CPropertyPage::OnPaint() for painting messages
}
//************************************************************************
// InitDialog
//
// Setup the display rect and start the timer.
//************************************************************************
BOOL CAbout::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_HyperLink2.SetURL(_T("http://www.ecufix.com/"));
m_HyperLink1.SetURL(_T("http://www.andywhittaker.com/ecu/"));
// m_HyperLink.SetUnderline(CHyperLink::ulAlways);
BOOL bRet;
UINT nRet;
nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
CClientDC dc(this);
bRet = m_dcMem.CreateCompatibleDC(&dc);
m_pDisplayFrame=(CWnd*)GetDlgItem(IDC_DISPLAY_STATIC);
// If you assert here, you did not assign your static display control
// the IDC_ value that was used in the GetDlgItem(...). This is the
// control that will display the credits.
_ASSERTE(m_pDisplayFrame);
m_pDisplayFrame->GetClientRect(&m_ScrollRect);
nRet = SetTimer(DISPLAY_TIMER_ID,DISPLAY_SPEED,NULL);
_ASSERTE(nRet != 0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//************************************************************************
// OnTimer
//
// On each of the display timers, scroll the window 1 unit. Each 20
// units, fetch the next array element and load into work string. Call
// Invalidate and UpdateWindow to invoke the OnPaint which will paint
// the contents of the newly updated work string.
//************************************************************************
void CAbout::OnTimer(UINT nIDEvent)
{
if (nIDEvent != DISPLAY_TIMER_ID)
{
CDialog::OnTimer(nIDEvent);
return;
}
if (!m_bProcessingBitmap)
if (nCounter++ % nCurrentFontHeight == 0) // every x timer events, show new line
{
nCounter=1;
m_szWork = pArrCredit[nArrIndex++];
if (nArrIndex > ARRAYCOUNT-1)
nArrIndex=0;
nClip = 0;
m_bDrawText=TRUE;
}
m_pDisplayFrame->ScrollWindow(0,SCROLLAMOUNT,&m_ScrollRect,&m_ScrollRect);
nClip = nClip + abs(SCROLLAMOUNT);
CRect rect;
CWnd* pWnd = GetDlgItem(IDC_DISPLAY_STATIC);
ASSERT_VALID(pWnd);
pWnd->GetClientRect(&rect);
pWnd->ClientToScreen(rect);
ScreenToClient(&rect);
InvalidateRect(rect,FALSE); // FALSE does not erase background
CPropertyPage::OnTimer(nIDEvent);
}
void CAbout::OnDestroy()
{
CPropertyPage::OnDestroy();
m_dcMem.SelectObject(CBitmap::FromHandle(m_hBmpOld));
m_bmpWork.DeleteObject();
KillTimer(DISPLAY_TIMER_ID);
}
void CAbout::OnShowWindow(BOOL bShow, UINT nStatus)
{
CPropertyPage::OnShowWindow(bShow, nStatus);
if (!bShow)
return;
// m_bProcessingBitmap=FALSE;
nArrIndex=0;
nCounter=1;
nClip=0;
m_bFirstTime=TRUE;
m_bDrawText=FALSE;
m_hBmpOld = 0;
}
void CAbout::OnStnClickedHyperlink2()
{
// TODO: Add your control notification handler code here
}