📄 splashwindow.cpp
字号:
// SplashWindow.cpp : implementation file
//
#include "stdafx.h"
#include "Final.h"
#include "SplashWindow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplashWindow dialog
CSplashWindow::CSplashWindow(CWnd* pParent /*=NULL*/)
: CDialog(CSplashWindow::IDD, pParent)
{
//{{AFX_DATA_INIT(CSplashWindow)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSplashWindow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSplashWindow)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSplashWindow, CDialog)
//{{AFX_MSG_MAP(CSplashWindow)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSplashWindow message handlers
BOOL CSplashWindow::OnInitDialog()
{
CDialog::OnInitDialog();
i=255;
CDialog::OnInitDialog();
CRect rtOld;
GetWindowRect(rtOld);
CPoint point = rtOld.TopLeft();
CRect rtNew = CRect(point,CSize(380,253));
MoveWindow(rtNew);
::SetWindowPos(GetSafeHwnd() , HWND_TOPMOST , rtNew.left ,rtNew.top , rtNew.Width() , rtNew.Height(), SWP_NOSIZE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSplashWindow::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(&rect);//得到窗体的大小
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAP1);//加载背景图片
BITMAP bitMap;
bmpBackground.GetBitmap(&bitMap);
CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);
}
void CSplashWindow::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
delete this; //so important
}
void CSplashWindow::OnOK()
{
CDialog::OnOK();
DestroyWindow();
}
void CSplashWindow::OnCancel()
{
CDialog::OnCancel();
DestroyWindow();
}
void CSplashWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
SetTimer(1,25,NULL);
hWindow=GetSafeHwnd();
HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
g_pSetLayeredWindowAttributes = (lpfn)GetProcAddress(hUser32,"SetLayeredWindowAttributes");
::SetWindowLong(hWindow,GWL_EXSTYLE,GetWindowLong(hWindow,GWL_EXSTYLE)^WS_EX_LAYERED);
CDialog::OnLButtonDown(nFlags, point);
}
void CSplashWindow::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
i=i-5;// TODO: Add your message handler code here and/or call default
g_pSetLayeredWindowAttributes(hWindow,0,i,2);
::RedrawWindow(hWindow, NULL, NULL,RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
if(i<=0)
{
KillTimer(1);
OnOK();
}
CDialog::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -