📄 splashscr.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// Splashscr.cpp: show the splash screen, kill the splash screen
//
#include "stdafx.h"
#include "splashscr.h"
#include "rtcs.h"
#define MAX_LOADSTRING 100
CSplashScreen::CSplashScreen( HINSTANCE hInstance, WORD wBmpID )
{
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: +CSplashScreen::CSplashScreen() this=0x%08x, ...\r\n", this ) );
hWndSplashScreen = NULL;
hInst = hInstance;
wBmpResID = wBmpID;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) CSplashScreen::SplashWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_VOIPDEMO ) );
wc.hCursor = 0;
wc.hbrBackground = ( HBRUSH ) GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = 0;
wc.lpszClassName = L"VOIPSPLASH";
if ( !RegisterClass( &wc ) )
if ( GetLastError() != ERROR_CLASS_ALREADY_EXISTS )
return;
TCHAR szTitle[ MAX_LOADSTRING ]; // The title bar text
LoadString( hInst, wBmpResID, szTitle, MAX_LOADSTRING );
hWndSplashScreen = CreateWindow( L"VOIPSPLASH", szTitle, WS_POPUP, 10, 40, 10, 10, NULL, NULL, hInst, NULL );
SetWindowLong( hWndSplashScreen, GWL_USERDATA, ( DWORD )this );
// Put in on the middle of the screen
int nSSCx = 300;
int nSSCy = 200;
int nScreenWidth = GetSystemMetrics( SM_CXFULLSCREEN );
int nScreenHeight = GetSystemMetrics( SM_CYFULLSCREEN );
int NewPosX = ( nScreenWidth - nSSCx ) / 2;
int NewPosY = ( nScreenHeight - nSSCy ) / 2;
// if the box is larger than the physical screen
if ( NewPosX < 0 )
NewPosX = 0;
if ( NewPosY < 0 )
NewPosY = 0;
SetWindowPos( hWndSplashScreen, 0, NewPosX, NewPosY, nSSCx, nSSCy, SWP_NOZORDER );
ShowWindow( hWndSplashScreen, SW_HIDE );
UpdateWindow( hWndSplashScreen );
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: -CSplashScreen::CSplashScreen()...\r\n" ) );
}
CSplashScreen::~CSplashScreen()
{
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: +CSplashScreen::~CSplashScreen()...\r\n" ) );
// Check if window has been destroyed yet
if ( hWndSplashScreen )
DestroyWindow( hWndSplashScreen );
hWndSplashScreen = NULL;
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: -CSplashScreen::~CSplashScreen()...\r\n" ) );
}
CSplashScreen::Show( BOOL bShow )
{
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: +CSplashScreen::Show()...\r\n" ) );
ShowWindow( hWndSplashScreen, ( bShow )?SW_SHOWNORMAL:SW_HIDE );
UpdateWindow( hWndSplashScreen );
DEBUGMSG( ZONE_STATUS|ZONE_INIT, ( L"VoipDemo: -CSplashScreen::Show()...\r\n" ) );
}
LRESULT CALLBACK CSplashScreen::SplashWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
CSplashScreen* pThis = ( CSplashScreen* )GetWindowLong( hWnd, GWL_USERDATA );
switch ( message )
{
case WM_CREATE:
break;
case WM_PAINT:
return pThis->DoSplashPaint( wParam, lParam );
// case WM_DESTROY:
// PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
LRESULT CSplashScreen::DoSplashPaint( WPARAM wParam, LPARAM lParam )
{
RECT rt;
PAINTSTRUCT ps;
HDC hdc = BeginPaint( hWndSplashScreen, &ps );
GetClientRect( hWndSplashScreen, &rt );
// Draw the splash image
HBITMAP hSplash = LoadBitmap( hInst, MAKEINTRESOURCE( wBmpResID ) );
HDC hBmpDC = CreateCompatibleDC( hdc );
HBITMAP hOldBmp = ( HBITMAP )SelectObject( hBmpDC, hSplash );
BITMAP sSplash;
memset( &sSplash, 0, sizeof( BITMAP ) );
GetObject( hSplash, sizeof( BITMAP ), &sSplash );
BitBlt( hdc, 0, 0, sSplash.bmWidth, sSplash.bmHeight, hBmpDC, 0, 0, SRCCOPY );
SelectObject( hBmpDC, hOldBmp );
DeleteDC( hBmpDC );
DeleteObject( hSplash );
EndPaint( hWndSplashScreen, &ps );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -