Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Splash screen in c++ : Beginner help

This topic is 5736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I want to create a splash screen that displays an image without a border (like install screens for games) with a couple buttons which will point to a .exe file. If anyone can help or offer any sites with examples or tutorials will be helpful Thanks in advance! (o)..A Bee bit my bottom, now my bottom Big..(o)

Share this post

Link to post
Share on other sites
you can also use WS_EX_TOOLWINDOW which won''t have any effect if you dont'' have a border, but will take away the task bar button if you want.

Share this post

Link to post
Share on other sites
There was a topic about this a while ago : http://www.gamedev.net/community/forums/topic.asp?topic_id=148053

Might come in handy, I hope....

Share this post

Link to post
Share on other sites
Yeah, that was my topic ;-)

So here is what I did:

- Created a window with WS_POPUP style (borderless)
- After calling CreateWindow captured part of desktop:

HDC hScrDC, hMemDC; // screen DC and memory DC

HGDIOBJ hOldBitmap , hBitmap;

// create a DC for the screen and create

// a memory DC compatible to screen DC

hMemDC = CreateCompatibleDC( hScrDC ); // get points of rectangle to grab

// create a bitmap compatible with the screen DC

hBitmap = CreateCompatibleBitmap( hScrDC, m_dwCreationWidth, m_dwCreationHeight );

// select new bitmap into memory DC

hOldBitmap = SelectObject( hMemDC, hBitmap );

// bitblt screen DC to memory DC

BitBlt( hMemDC, 0, 0, m_dwCreationWidth, m_dwCreationHeight, hScrDC, m_rcWindowBounds.right/2 - m_dwCreationWidth/2, m_rcWindowBounds.bottom/2 - m_dwCreationHeight/2, SRCCOPY );

// select old bitmap back into memory DC and get handle to

// bitmap of the screen

hBitmap = SelectObject( hMemDC, hOldBitmap );

// clean up

DeleteDC( hScrDC );
DeleteDC( hMemDC );

// return handle to the bitmap

m_hScreenBitmap = ( HBITMAP )hBitmap;

- Blitting the screenshot onto the borderless window in the

MsgProcs' WM_PAINT part:

RECT rc;

// Get windows' boundings

GetClientRect( m_pGD->g_hWnd, &rc );

// Display the splash bitmap in the window

HDC hDCWindow = GetDC( m_hWnd );
HDC hDCScreenImage = CreateCompatibleDC( NULL );

// Select screenshot into device context

SelectObject( hDCScreenImage, m_hScreenBitmap );

// Retrieve screenshots' properties

GetObject( m_hScreenBitmap, sizeof( bmp ), &bmp );

// Blit screenshot onto the desktop

StretchBlt( hDCWindow, rc.right/2 - bmp.bmWidth/2, rc.bottom/2 - bmp.bmHeight/2, bmp.bmWidth, bmp.bmHeight, hDCScreenImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY );

- Alphablended the splash screen (24bit tga file with alphamask) onto the screenshot:

// Load splash bitmap

if( m_hSplashBitmap == NULL )
m_hSplashBitmap = Load32bppTgaLB( "Splash.tga", true );

// Create a device context for the splash bitmap

HDC hDCSplashImage = CreateCompatibleDC( NULL );

// Select splash bitmap into the device context

SelectObject( hDCSplashImage, m_hSplashBitmap );

// Get the splash bitmaps' properties

GetObject( m_hSplashBitmap, sizeof( bmp ), &bmp );

// Define per-pixel alpha blending function

BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };

// Blend the splash bitmap onto the window

AlphaBlend(hDCWindow, 0, 0, bmp.bmWidth, bmp.bmHeight, hDCSplashImage, 0, 0, bmp.bmWidth, bmp.bmHeight, pixelblend );

- Cleaned up some stuff:

// Clean up

DeleteDC( hDCSplashImage );
DeleteDC( hDCScreenImage );
ReleaseDC( m_pGD->g_hWnd, hDCWindow );

Hope that helps you a bit ... the source has to be modified to work under different environments, since there are several project dependent variables you probably won't have, but it should make clear how things work ...

[edited by - Balthazaar on April 3, 2003 1:38:00 AM]

[edited by - Balthazaar on April 3, 2003 1:39:52 AM]

Share this post

Link to post
Share on other sites
Use a dialog box in the Resource Editor and its one line: DialogBox(NULL, "SPLASH", NULL, SplashDlgProc). Make sure you click the "Center" check box.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!