Microsoft Visual C++ MFC. Win95 WinNT


CSplashWnd - 2


2.2. Splash.cpp

// CG: Splash.cpp

// Splash Screen

// CSplashWnd

 

#include "stdafx.h"

#include "resource.h"

 

#include "Splash.h"

 

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char BASED_CODE THIS_FILE[] = __FILE__;

#endif

 

//////////////////////////////////////////////////////////////

// Splash Screen class

 

BOOL CSplashWnd::c_bShowSplashWnd;

CSplashWnd* CSplashWnd::c_pSplashWnd;

CSplashWnd::CSplashWnd()

{

}

 

CSplashWnd::~CSplashWnd()

{

// Clear the static window pointer.

ASSERT(c_pSplashWnd == this);

c_pSplashWnd = NULL;

}

 

BEGIN_MESSAGE_MAP(CSplashWnd, CWnd)

//{{AFX_MSG_MAP(CSplashWnd)

ON_WM_CREATE()

ON_WM_PAINT()

ON_WM_TIMER()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/)

{

c_bShowSplashWnd = bEnable;

}

 

void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)

{

if (!c_bShowSplashWnd c_pSplashWnd != NULL)

return;

 

// Allocate a new splash screen, and create the window.

c_pSplashWnd = new CSplashWnd;

if (!c_pSplashWnd->Create(pParentWnd))

delete c_pSplashWnd;

else

c_pSplashWnd->UpdateWindow();

}

 

BOOL CSplashWnd::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




- -  - -  - -