⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashwnd.cpp

📁 wince WM5 loading等待窗口源码
💻 CPP
字号:
// SplashWnd.cpp : implementation of the CSplashWnd class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SplashWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSplashWnd class

CSplashWnd* CSplashWnd::m_pSplashWnd = NULL;

CSplashWnd::CSplashWnd() : m_nIDImage(0), m_nDelay(0), m_nTimer(0)
{
}

CSplashWnd::~CSplashWnd()
{
	// Clear the static window pointer.
	ASSERT(m_pSplashWnd == this);
	m_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::ShowSplashScreen(UINT nIDImage, UINT nDelay,
								  CWnd* pParentWnd /*= NULL*/)
{
	if (m_pSplashWnd != NULL)
		return;

	// Allocate a new splash screen, and create the window.
	m_pSplashWnd = new CSplashWnd;
   	m_pSplashWnd->m_nIDImage = nIDImage;
    m_pSplashWnd->m_nDelay = nDelay;

	if (!m_pSplashWnd->Create(pParentWnd))
		delete m_pSplashWnd;
	else m_pSplashWnd->UpdateWindow();
}

BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg)
{
	if (m_pSplashWnd == NULL)
		return FALSE;

	// If we get a keyboard or mouse (stylus) 
	// 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)
	{
		m_pSplashWnd->HideSplashScreen();
		return TRUE; // message handled here
	}

	return FALSE; // message not handled
}

BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/)
{
	if(!m_bitmap.LoadBitmap(m_nIDImage)) 
		return FALSE;

	BITMAP bmp;
	m_bitmap.GetBitmap(&bmp);

	return CreateEx(0, 
		AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
		NULL, WS_POPUP | WS_VISIBLE, 0, 0, bmp.bmWidth, bmp.bmHeight, 
		pParentWnd->GetSafeHwnd(), NULL);
}

void CSplashWnd::HideSplashScreen()
{
	// Destroy the window, and update the mainframe.
	KillTimer(m_nTimer);
	DestroyWindow();
	AfxGetMainWnd()->UpdateWindow();
}

void CSplashWnd::PostNcDestroy()
{
	// Free the C++ class.
	delete this;
}

int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// Center the window.
	CenterWindow();

	// Set a timer to destroy the splash screen.
	m_nTimer = SetTimer(1, m_nDelay, NULL);

	return 0;
}

void CSplashWnd::OnPaint()
{
	CPaintDC dc(this);

	CDC dcImage;
	if (!dcImage.CreateCompatibleDC(&dc))
		return;

	BITMAP bmp;
	m_bitmap.GetBitmap(&bmp);

	// Paint the image.
	CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
	dc.BitBlt(0, 0, bmp.bmWidth, bmp.bmHeight, &dcImage, 0, 0, SRCCOPY);
	dcImage.SelectObject(pOldBitmap);
}

void CSplashWnd::OnTimer(UINT nIDEvent)
{
	// Destroy the splash screen window.
	HideSplashScreen();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -