-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutDialog.cpp
More file actions
executable file
·200 lines (164 loc) · 4.21 KB
/
AboutDialog.cpp
File metadata and controls
executable file
·200 lines (164 loc) · 4.21 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
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
/**
* This file is a part of IC Login (c) Daniel Bratell 2000
*
* That the source code is publicized on Internet does not mean that
* it's free to use. You are allowed to be inspired by it, but if you
* do patches of your own you must submit them to the original author.
*
* Also, you mustn't redistribute the source code. If you want to
* make other people see it, point them to
*
* http://www.lysator.liu.se/~bratell/iclogin/
*
* Original Author: Daniel Bratell <bratell@lysator.liu.se>
*/
// AboutDialog.cpp : implementation file
//
#include "stdafx.h"
#include "iclogin.h"
#include "AboutDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define SCROLLWIDTH 30
#define SCROLLINTERVAL 130
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAboutDialog::IDD, pParent),
m_scrolloffset(0)
{
//{{AFX_DATA_INIT(CAboutDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_credits.LoadString(IDS_CREDITS);
m_credits += _T(" ");
}
void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDialog)
DDX_Control(pDX, IDC_SCROLLTEXT, m_scrolltext);
DDX_Control(pDX, IDC_APPURL, m_appurl);
DDX_Control(pDX, IDC_VERSIONLABEL, m_versionlabel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)
//{{AFX_MSG_MAP(CAboutDialog)
ON_BN_CLICKED(IDC_APPURL, OnAppurl)
ON_WM_DESTROY()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#define SCROLLTIMER 4342
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog message handlers
BOOL CAboutDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_versionlabel.SetWindowText(IC_VERSIONSTRING);
m_appurl.SetWindowText(IC_APPURL);
// TODO: Add extra initialization here
SetScrollText();
SetTimer(SCROLLTIMER, SCROLLINTERVAL, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
typedef HINSTANCE (__stdcall *ShellExecuteFunc)(HWND hwnd, LPCTSTR lpVerb, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd);
void CAboutDialog::OnAppurl()
{
// This is the only use of shell.dll which is a large dll. Better to
// open it dynamically, since people don't care about working set when
// judging a program.
HINSTANCE shell32dll = LoadLibrary(_T("shell32.dll"));
if(!shell32dll)
{
return;
}
ShellExecuteFunc func;
#ifdef _UNICODE
func = (ShellExecuteFunc)GetProcAddress(shell32dll, "ShellExecuteW");
#else
func = (ShellExecuteFunc)GetProcAddress(shell32dll, "ShellExecuteA");
#endif
if(func)
{
func(*this, NULL, IC_APPURL, NULL, "", SW_RESTORE);
}
FreeLibrary(shell32dll);
}
/**
* CREDITS:
* Jonas Svensson (testare, idéspruta)
* Andréas Bratell (testare, idévulkan)
* Marcus Comstedt (vars script gav insikt i hur nya inloggningssystemet fungerade)
* Calle Englund (dito)
*/
void CAboutDialog::OnDestroy()
{
KillTimer(SCROLLTIMER);
CDialog::OnDestroy();
}
void CAboutDialog::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case SCROLLTIMER:
SetScrollText();
break;
default:
CDialog::OnTimer(nIDEvent);
}
}
void CAboutDialog::SetScrollText()
{
int length = m_credits.GetLength();
if(length == 0)
{
ASSERT(false);
m_scrolltext.SetWindowText(_T(""));
return;
}
CString toshow = m_credits.Right(length-m_scrolloffset);
while(toshow.GetLength() < SCROLLWIDTH)
{
toshow += m_credits;
}
if(toshow.GetLength() > SCROLLWIDTH) // XXX Magic
{
toshow = toshow.Left(SCROLLWIDTH);
}
m_scrolltext.SetWindowText(toshow);
_TCHAR letter = m_credits.GetAt(m_scrolloffset);
++m_scrolloffset;
if(CharWidth(letter < 6))
{
++m_scrolloffset;
}
if(m_scrolloffset >= length)
{
m_scrolloffset = m_scrolloffset % length;
}
CString mess;
mess.Format("%c is %d wide.\n", letter, CharWidth(letter));
TRACE(mess);
}
inline int CAboutDialog::CharWidth(_TCHAR letter)
{
int rv=8;
CDC *dc = GetDC();
if(!dc)
{
ASSERT(false);
return 8;
}
int width;
if(dc->GetCharWidth(letter, letter, &width))
{
rv = width;
}
ReleaseDC(dc);
return rv;
}