/
AboutDlg.cpp
216 lines (179 loc) · 5.2 KB
/
AboutDlg.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
/*
* AboutDlg.cpp : Twitter クライアント chirrup
* 版数(バージョン番号)表示
*
* written by H.Tsujimura 4 Apr 2007
*
* Copyright (c) 2007 by H.Tsujimura (tsupo@na.rim.or.jp)
* All Rights Reserved.
*
* $Log: /comm/chirrup/AboutDlg.cpp $
*
* 1 09/05/14 3:50 tsupo
* (1) ビルド環境のディレクトリ構造を整理
* (2) VSSサーバ拠点を変更
*
* 4 09/03/23 21:06 Tsujimura543
* libpng と zlib の版数も表示するようにした
*
* 3 08/11/27 15:18 Tsujimura543
* OpenSSL と iconv の版数を表示するようにした
*
* 2 07/06/13 1:25 Tsujimura543
* ダイアログに表示するバージョン番号情報をリソースファイルから
* 拾ってくるようにした
*
* 1 07/04/05 2:06 Tsujimura543
* 最初の版
*/
#include "chirrup.h"
#include "AboutDlg.h"
#include "png.h"
#ifndef lint
static char *rcs_id =
"$Header: /comm/chirrup/AboutDlg.cpp 1 09/05/14 3:50 tsupo $";
#endif
#if (WINVER >= 0x0500)
//#define IDC_HAND MAKEINTRESOURCE(32649)
#ifdef IDC_HAND
#undef IDC_HAND
#endif
#endif /* WINVER >= 0x0500 */
#define IDC_HAND IDC_HAND2
/* libpng 版数取得 */
char *
getLibpngVersion( char *buf, size_t bufSize )
{
char *p = buf;
char *q;
size_t sz = bufSize;
static char version[BUFSIZ];
if ( !buf || (bufSize == 0) ) {
p = version;
sz = BUFSIZ;
}
q = png_get_copyright(NULL);
while ( (*q == ' ') || (*q == '\t') || (*q == '\r') || (*q == '\n') )
q++;
strncpy( p, q, sz - 1 );
p[sz - 1] = NUL;
return ( p );
}
/* zlib 版数取得 */
char *
getZlibVersion( char *buf, size_t bufSize )
{
char *p = buf;
size_t sz = bufSize;
static char version[BUFSIZ];
sprintf( version, "zlib: %s", zlibVersion() );
if ( buf && (bufSize > 0) ) {
strncpy( p, version, sz - 1 );
p[sz - 1] = NUL;
}
else
p = version;
return ( p );
}
/////////////////////////////////////////////////////////////////////////////
// アプリケーションのバージョン情報で使われている CAboutDlg ダイアログ
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
m_hCursor = AfxGetApp()->LoadCursor( IDC_HAND );
}
CAboutDlg::~CAboutDlg()
{
m_cFont.DeleteObject();
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(IDC_MAIL_ADDR, OnMailAddr)
ON_BN_CLICKED(IDC_WEB_URL, OnWebUrl)
ON_WM_SETCURSOR()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAboutDlg::OnMailAddr()
{
CString cmd;
cmd.LoadString( IDS_MAIL_ADDR );
ShellExecute( NULL, "open", cmd, NULL, NULL, SW_SHOWNORMAL );
}
void CAboutDlg::OnWebUrl()
{
CString cmd;
cmd.LoadString( IDS_WEB_URL );
ShellExecute( NULL, "open", cmd, NULL, NULL, SW_SHOWNORMAL );
}
BOOL CAboutDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if ( nHitTest == HTCLIENT ) {
// Web の URLかメールアドレスにマウスポインタが来たら、
// 指カーソルを表示する
DWORD dwPos = GetMessagePos();
WORD wX = LOWORD( dwPos );
WORD wY = HIWORD( dwPos );
CPoint poCursor( wX, wY );
CRect rcClient;
CStatic *s = (CStatic *)GetDlgItem( IDC_MAIL_ADDR );
s->GetWindowRect( &rcClient );
if ( (wX >= rcClient.left) && (wX <= rcClient.right) &&
(wY >= rcClient.top) && (wY <= rcClient.bottom) ) {
SetCursor( m_hCursor );
return TRUE;
}
s = (CStatic *)GetDlgItem( IDC_WEB_URL );
s->GetWindowRect( &rcClient );
if ( (wX >= rcClient.left) && (wX <= rcClient.right) &&
(wY >= rcClient.top) && (wY <= rcClient.bottom) ) {
SetCursor( m_hCursor );
return TRUE;
}
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CAboutDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
if ( bShow ) {
// Web の URLとメールアドレスを下線付きで表示する
LOGFONT tLogFont;
CFont *cWndFont;
cWndFont = GetFont();
cWndFont->GetLogFont( &tLogFont );
tLogFont.lfUnderline = 1;
m_cFont.CreateFontIndirect( &tLogFont );
CStatic *s = (CStatic *)GetDlgItem( IDC_MAIL_ADDR );
s->SetFont( &m_cFont, TRUE );
s = (CStatic *)GetDlgItem( IDC_WEB_URL );
s->SetFont( &m_cFont, TRUE );
CString version;
version.LoadString( IDS_VERSION );
CString title = _T("chirrup Version ");
title += version;
s = (CStatic *)GetDlgItem( IDC_VERSION );
s->SetWindowText( title );
// OpenSSL 版数表示
char buf[BUFSIZ];
size_t sz = BUFSIZ;
s = (CStatic *)GetDlgItem( IDC_OPENSSL );
s->SetWindowText( getOpenSSLversion( buf, sz ) );
// iconv 版数表示
s = (CStatic *)GetDlgItem( IDC_ICONV );
s->SetWindowText( getIconvVersion( buf, sz ) );
// libpng 版数表示
s = (CStatic *)GetDlgItem( IDC_LIBPNG );
s->SetWindowText( getLibpngVersion( buf, sz ) );
// zlib 版数表示
s = (CStatic *)GetDlgItem( IDC_ZLIB );
s->SetWindowText( getZlibVersion( buf, sz ) );
}
}