-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDlgSplash.cpp
More file actions
193 lines (145 loc) · 4.33 KB
/
DlgSplash.cpp
File metadata and controls
193 lines (145 loc) · 4.33 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
/*******************************************************************
// Copyright (c) 2002, 2003, 2004, 2005,
// Robert Umbehant
// mailto:rumbehant@wheresjames.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA
//
*******************************************************************/
// DlgSplash.cpp : implementation file
//
#include "stdafx.h"
#include "vp.h"
#include "DlgSplash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TIMERID 101
/////////////////////////////////////////////////////////////////////////////
// CDlgSplash dialog
CDlgSplash::CDlgSplash(CWnd* pParent /*=NULL*/)
: CDialog(CDlgSplash::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgSplash)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bRun = FALSE;
m_dwMinDisplay = 3000;
m_uTimerId = 0;
m_hCenter = NULL;
}
void CDlgSplash::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgSplash)
DDX_Control(pDX, IDC_IMG, m_img);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgSplash, CDialog)
//{{AFX_MSG_MAP(CDlgSplash)
ON_WM_SIZE()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgSplash message handlers
BOOL CDlgSplash::OnInitDialog()
{
CDialog::OnInitDialog();
// Size window
Size();
// Set on top and center us up
::SetWindowPos( GetSafeHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE );
// Center the splash box
if ( m_hCenter != NULL ) CenterWindow( CWnd::FromHandle( m_hCenter ) );
else CenterWindow( GetDesktopWindow() );
// Set the timer
m_uTimerId = ::SetTimer( GetSafeHwnd(), TIMERID, m_dwMinDisplay, NULL );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgSplash::Size()
{
// Punt if no window
if ( !::IsWindow( GetSafeHwnd() ) ) return;
long cx = m_img.GetWidth();
long cy = m_img.GetHeight();
// Set bitmap to the same size as the image
::SetWindowPos( GetSafeHwnd(), NULL, 0, 0, cx, cy,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE );
// Size image
CWnd *pWnd = GetDlgItem( IDC_IMG );
if ( pWnd != NULL ) pWnd->SetWindowPos( NULL, 0, 0, cx, cy,
SWP_NOZORDER | SWP_NOACTIVATE );
}
BOOL CDlgSplash::Run( HWND hWnd, DWORD img, LPCTSTR pType, DWORD idd, DWORD dwMinDisplay )
{
m_bRun = TRUE;
m_dwMinDisplay = dwMinDisplay;
if ( idd == NULL ) idd = IDD;
m_hCenter = hWnd;
// Load the splash image
m_img.Load( MAKEINTRESOURCE( img ), "BUFFER", pType );
// Create the splash box
if ( !Create( idd, GetDesktopWindow() ) ) return FALSE;
// We want to see it
ShowWindow( SW_SHOWNORMAL );
return TRUE;
}
void CDlgSplash::End()
{
m_bRun = FALSE;
}
void CDlgSplash::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
Size();
}
void CDlgSplash::OnTimer(UINT nIDEvent)
{
if ( nIDEvent = TIMERID )
{
// Is it time to quit?
if ( !m_bRun )
{
// Lose previous timer
if ( m_uTimerId != 0 )
{ ::KillTimer( GetSafeHwnd(), TIMERID );
m_uTimerId = 0;
} // end if
// Kill the splash box
DestroyWindow();
} // end if
else if ( m_dwMinDisplay != 1000 )
{
// Change timer to 1 second
m_dwMinDisplay = 1000;
// Lose previous timer
if ( m_uTimerId != 0 )
{ ::KillTimer( GetSafeHwnd(), TIMERID );
m_uTimerId = 0;
} // end if
// Keep checking every second for run stop
m_uTimerId = ::SetTimer( GetSafeHwnd(), TIMERID, 1000, NULL );
} // end else if
} // end if
CDialog::OnTimer(nIDEvent);
}
BOOL CDlgSplash::DestroyWindow()
{
return CDialog::DestroyWindow();
}