-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathABOUTBOX.cpp
214 lines (174 loc) · 5.35 KB
/
ABOUTBOX.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
#include "stdafx.h"
#include "resource.h"
#include "aboutbox.h"
#include <dos.h>
#include <direct.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutBox dialog
BEGIN_MESSAGE_MAP(CAboutBox, CDialog)
//{{AFX_MSG_MAP(CAboutBox)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CAboutBox::CAboutBox(CWnd* pParent /*=NULL*/)
: CDialog(CAboutBox::IDD, pParent)
{
//{{AFX_DATA_INIT(CAboutBox)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAboutBox::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutBox)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CAboutBox message handlers
BOOL CAboutBox::OnInitDialog()
{
CDialog::OnInitDialog();
// initialize the big icon control
m_icon.SubclassDlgItem(IDC_BIGICON, this);
m_icon.SizeToContent();
// fill available memory
CString str, strFmt;
strFmt.LoadString(IDS_AVAIL_MEM);
wsprintf(str.GetBuffer(80), strFmt, GetFreeSpace(0) / 1024L);
str.ReleaseBuffer();
SetDlgItemText(IDC_AVAIL_MEM, str);
// fill math coprocessor information
if (GetWinFlags() & WF_80x87)
str.LoadString(IDS_MATH_COPR_PRESENT);
else
str.LoadString(IDS_MATH_COPR_NOTPRESENT);
SetDlgItemText(IDC_MATH_COPR, str);
// fill disk free information
struct _diskfree_t diskfree;
if (_dos_getdiskfree(_getdrive(), &diskfree) == 0)
{
strFmt.LoadString(IDS_DISK_SPACE);
wsprintf(str.GetBuffer(80), strFmt,
(DWORD)diskfree.avail_clusters *
(DWORD)diskfree.sectors_per_cluster *
(DWORD)diskfree.bytes_per_sector / (DWORD)1024L);
str.ReleaseBuffer();
}
else
str.LoadString(IDS_DISK_SPACE_UNAVAIL);
SetDlgItemText(IDC_DISK_SPACE, str);
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
// CSplashWnd dialog
BEGIN_MESSAGE_MAP(CSplashWnd, CDialog)
//{{AFX_MSG_MAP(CSplashWnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CSplashWnd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSplashWnd)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CSplashWnd::Create(CWnd* pParent)
{
//{{AFX_DATA_INIT(CSplashWnd)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
if (!CDialog::Create(CSplashWnd::IDD, pParent))
{
TRACE0("Warning: creation of CSplashWnd dialog failed\n");
return FALSE;
}
return TRUE;
}
BOOL CSplashWnd::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
// initialize the big icon control
m_icon.SubclassDlgItem(IDC_BIGICON, this);
m_icon.SizeToContent();
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
// CSplashWnd message handlers
/////////////////////////////////////////////////////////////////////////////
// CBigIcon
BEGIN_MESSAGE_MAP(CBigIcon, CButton)
//{{AFX_MSG_MAP(CBigIcon)
ON_WM_DRAWITEM()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBigIcon message handlers
#define CY_SHADOW 4
#define CX_SHADOW 4
void CBigIcon::SizeToContent()
{
// get system icon size
int cxIcon = ::GetSystemMetrics(SM_CXICON);
int cyIcon = ::GetSystemMetrics(SM_CYICON);
// a big icon should be twice the size of an icon + shadows
SetWindowPos(NULL, 0, 0, cxIcon*2 + CX_SHADOW + 4, cyIcon*2 + CY_SHADOW + 4,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
}
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
ASSERT(pDC != NULL);
CRect rect;
GetClientRect(rect);
int cxClient = rect.Width();
int cyClient = rect.Height();
// load icon
HICON hicon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
if (hicon == NULL)
return;
// draw icon into off-screen bitmap
int cxIcon = ::GetSystemMetrics(SM_CXICON);
int cyIcon = ::GetSystemMetrics(SM_CYICON);
CBitmap bitmap;
if (!bitmap.CreateCompatibleBitmap(pDC, cxIcon, cyIcon))
return;
CDC dcMem;
if (!dcMem.CreateCompatibleDC(pDC))
return;
CBitmap* pBitmapOld = dcMem.SelectObject(&bitmap);
if (pBitmapOld == NULL)
return;
// blt the bits already on the window onto the off-screen bitmap
dcMem.StretchBlt(0, 0, cxIcon, cyIcon, pDC,
2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4, SRCCOPY);
// draw the icon on the background
dcMem.DrawIcon(0, 0, hicon);
// draw border around icon
CPen pen;
pen.CreateStockObject(BLACK_PEN);
CPen* pPenOld = pDC->SelectObject(&pen);
pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW);
if (pPenOld)
pDC->SelectObject(pPenOld);
// draw shadows around icon
CBrush br;
br.CreateStockObject(DKGRAY_BRUSH);
rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient);
pDC->FillRect(rect, &br);
rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient);
pDC->FillRect(rect, &br);
// draw the icon contents
pDC->StretchBlt(2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4,
&dcMem, 0, 0, cxIcon, cyIcon, SRCCOPY);
}
BOOL CBigIcon::OnEraseBkgnd(CDC*)
{
return TRUE; // we don't do any erasing...
}
/////////////////////////////////////////////////////////////////////////////