home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Windows Gam…ming Gurus (2nd Edition)
/
Disc2.iso
/
common
/
msdev98
/
bin
/
ide
/
splash.dll
/
TEMPLATE
/
138
< prev
Wrap
Text File
|
1998-06-18
|
3KB
|
142 lines
// CG: This file was added by the Splash Screen component.
// $$VAL:ImplemName$$ : implementation file
//
#include "$$VAL:ProjHdrName$$" // e. g. stdafx.h
#include "$$VAL:ResHdrName$$" // e.g. resource.h
#include "$$VAL:HeaderName$$" // e.g. splash.h
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Splash Screen class
BOOL $$VAL:SplClassName$$::c_bShowSplashWnd;
$$VAL:SplClassName$$* $$VAL:SplClassName$$::c_pSplashWnd;
$$VAL:SplClassName$$::$$VAL:SplClassName$$()
{
}
$$VAL:SplClassName$$::~$$VAL:SplClassName$$()
{
// Clear the static window pointer.
ASSERT(c_pSplashWnd == this);
c_pSplashWnd = NULL;
}
BEGIN_MESSAGE_MAP($$VAL:SplClassName$$, CWnd)
//{{AFX_MSG_MAP($$VAL:SplClassName$$)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void $$VAL:SplClassName$$::EnableSplashScreen(BOOL bEnable /*= TRUE*/)
{
c_bShowSplashWnd = bEnable;
}
void $$VAL:SplClassName$$::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)
{
if (!c_bShowSplashWnd || c_pSplashWnd != NULL)
return;
// Allocate a new splash screen, and create the window.
c_pSplashWnd = new $$VAL:SplClassName$$;
if (!c_pSplashWnd->Create(pParentWnd))
delete c_pSplashWnd;
else
c_pSplashWnd->UpdateWindow();
}
BOOL $$VAL:SplClassName$$::PreTranslateAppMessage(MSG* pMsg)
{
if (c_pSplashWnd == NULL)
return FALSE;
// If we get a keyboard or mouse message, hide the splash screen.
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN ||
pMsg->message == WM_NCRBUTTONDOWN ||
pMsg->message == WM_NCMBUTTONDOWN)
{
c_pSplashWnd->HideSplashScreen();
return TRUE; // message handled here
}
return FALSE; // message not handled
}
BOOL $$VAL:SplClassName$$::Create(CWnd* pParentWnd /*= NULL*/)
{
if (!m_bitmap.LoadBitmap($$VAL:BmpID16$$))
return FALSE;
BITMAP bm;
m_bitmap.GetBitmap(&bm);
return CreateEx(0,
AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL);
}
void $$VAL:SplClassName$$::HideSplashScreen()
{
// Destroy the window, and update the mainframe.
DestroyWindow();
AfxGetMainWnd()->UpdateWindow();
}
void $$VAL:SplClassName$$::PostNcDestroy()
{
// Free the C++ class.
delete this;
}
int $$VAL:SplClassName$$::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Center the window.
CenterWindow();
// Set a timer to destroy the splash screen.
SetTimer(1, 750, NULL);
return 0;
}
void $$VAL:SplClassName$$::OnPaint()
{
CPaintDC dc(this);
CDC dcImage;
if (!dcImage.CreateCompatibleDC(&dc))
return;
BITMAP bm;
m_bitmap.GetBitmap(&bm);
// Paint the image.
CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
dcImage.SelectObject(pOldBitmap);
}
void $$VAL:SplClassName$$::OnTimer(UINT nIDEvent)
{
// Destroy the splash screen window.
HideSplashScreen();
}