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

📄 splashdlg.cpp

📁 beereader source code
💻 CPP
字号:
// SplashDlg.cpp : implementation file
//

#include "stdafx.h"
#include "BeeReader.h"
#include "SplashDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSplashDlg dialog


CSplashDlg::CSplashDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSplashDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSplashDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_nBitmapWidth = 480;
	m_nBitmapHeight = 320;
	m_bCreate = FALSE;
	m_nxPos = m_nyPos = 0;
	m_szStatus = _T("启动初始化...");
}


void CSplashDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSplashDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSplashDlg, CDialog)
	//{{AFX_MSG_MAP(CSplashDlg)
	ON_WM_SIZE()
	ON_WM_PAINT()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_SYSTEM_LOAD,OnSystemLoading)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSplashDlg message handlers

BOOL CSplashDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	BITMAP bm;

	m_bitmap.DeleteObject();
	if (!m_bitmap.LoadBitmap(IDB_SPLASH))
		return FALSE;
	
	GetObject(m_bitmap.GetSafeHandle(), sizeof(bm), &bm);
	m_nBitmapWidth=bm.bmWidth;
	m_nBitmapHeight=bm.bmHeight;

	m_nxPos=(GetSystemMetrics(SM_CXFULLSCREEN)-bm.bmWidth)/2;
	m_nyPos=(GetSystemMetrics(SM_CYFULLSCREEN)-bm.bmHeight)/2;

	m_bCreate = TRUE;
    SetWindowPos(NULL,m_nxPos,m_nyPos,m_nBitmapWidth,m_nBitmapHeight,SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE);

	LOGFONT lf;
	CFont *myFont=CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));
	myFont->GetLogFont(&lf);
	m_myFont.DeleteObject();
	m_myFont.CreateFontIndirect(&lf);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSplashDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if( m_bCreate )
	{	   
	   SetWindowPos(NULL,m_nxPos,m_nyPos,m_nBitmapWidth,m_nBitmapHeight,SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE);
	}

}

void CSplashDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CDC memDC;
	CBitmap *pOldBitmap;
	
	// Blit Background
	memDC.CreateCompatibleDC(&dc);
	pOldBitmap=memDC.SelectObject(&m_bitmap);
	dc.BitBlt(0,0,m_nBitmapWidth,m_nBitmapHeight,&memDC,0,0,SRCCOPY);
	memDC.SelectObject(pOldBitmap);

	// Write Version
	CFont *pOldFont;
	pOldFont=dc.SelectObject(&m_myFont);
	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(RGB(0,0,0));
	CRect rc( m_nBitmapWidth-200,m_nBitmapHeight-35,m_nBitmapWidth-15,m_nBitmapHeight-10);
	dc.DrawText(_T("版本号:0.9 beta [Bulid 1214]"),&rc,DT_CENTER|DT_VCENTER|DT_WORDBREAK);
	
	//Write system loading status.
	rc.left = 10;
	rc.top = m_nBitmapHeight-35;
	rc.right = m_nBitmapWidth-210;
	rc.bottom = m_nBitmapHeight-10;
	dc.DrawText( m_szStatus,&rc,DT_LEFT|DT_VCENTER|DT_WORDBREAK);
    
	dc.SelectObject(pOldFont);
	// Do not call CDialog::OnPaint() for painting messages
}

BOOL CSplashDlg::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	
	return CDialog::OnEraseBkgnd(pDC);
}

LRESULT CSplashDlg::OnSystemLoading(WPARAM wParam, LPARAM lParam)
{
    return 0;
}

void CSplashDlg::UpdateLoadingStatus(int iTag, CString szStatus)
{
     CRect rect(10,m_nBitmapHeight-35,m_nBitmapWidth-210,m_nBitmapHeight-10);
     m_szStatus = szStatus;
	 
	 InvalidateRect(&rect);
     UpdateWindow();
}

⌨️ 快捷键说明

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