0

I have used the source files as found at http://www.codeproject.com/Articles/15523/Own-thread-Win32-splash-screen to create a splash screen for a Dedicated Gameserver GUI. This splash screen is pictured below:

enter image description here

This is the problem:

enter image description here

As can be seen, the window background isn't transparent. I've messed around with the actual image in Adobe Illustrator, but I can confirm that the image isn't at fault.

I have tried following these threads/instructions to make the window go transparent, in order to see the full affect of the splash screen, but they have failed to come up with a solution: Creating a transparent window in C++ Win32 How to create fully transparent window which has not transparent content? http://www.overclock.net/t/1113233/solved-c-semi-transparent-window

They all use different methods to create the splash screen, but some of the solutions should work for me. What am I doing wrong here?

Edit: The question is, how do I go about (successfully) making my window transparent?

Community
  • 1
  • 1
AStopher
  • 3,652
  • 10
  • 46
  • 67
  • Wait, what's the problem? How do they not work? it looks transparent to me. – Cody Gray Apr 29 '14 at 00:31
  • I apologize- the other screenshot is now uploaded properly, and it can clearly be seen that the window isn't transparent – AStopher Apr 29 '14 at 00:37
  • What's the format of the image and, more particularly, how are you loading it? Hope you're not trying to use LoadImage or one of the other GDI functions. You need to load the image with GDI+ if you want to load all 32 bits for each pixel. You should update your question to include the following: (1) the image loading code and (2) the image drawing code. – enhzflep Apr 29 '14 at 03:01
  • The format is .png 48. As I said before, I've using the code here for it: http://www.codeproject.com/Articles/15523/Own-thread-Win32-splash-screen – AStopher Apr 29 '14 at 08:36

1 Answers1

2

The question remains somewhat unclear to me, but I'll take a stab at answering it anyway. Correct me if I'm wrong, I'm happy to delete or revise this answer…

As I understand it, the first image that you posted is the raw starting image—the one you want to appear as the splash screen. You know, Adobe Photoshop-style.

Along those lines, I assume that the area you want to be drawn transparently is the gray gradient area above and behind the stylized Bohr model. This would effectively mirror the effect achieved by Adobe's splash screen(s), where ornaments appear to "hang off" the border of the rectangular splash screen because they have a transparent background.

The problem is that the area you want to be transparent is not transparent in the original image. Neither is it a solid color, which can be knocked out in order to simulate transparency.

In fact, that's exactly how the answers to the linked question suggested to create a transparent window:

  1. Create a top-level window of the appropriate size, and make it a layered window by setting the WS_EX_LAYERED extended window flag.
  2. Paint its background with your splash screen image in response to the WM_PAINT message.
  3. Call the SetLayeredWindowAttributes function with the LWA_COLORKEY flag to set a mask color in the splash screen image that will become transparent.

In order for this to work, the mask color needs to fill the area that you want to appear transparent. A common choice for this mask color is fuchsia (RGB = 255, 0, 255)—a fuchsed up color (credit to Hans Passant for this turn of phrase!) that is unlikely to appear anywhere else in an image.

This also allows you to do everything using simply GDI. No dependency on GDI+ required, and also likely to be slightly faster. With a splash screen, you want the thing to appear on the screen absolutely as quickly as possible.

You can, of course, do more complicated things, like using the BLENDFUNCTION and/or an image with pre-multiplied alpha channel values. But I'd avoid all the effort unless absolutely necessary. Your users are going to see this splash screen for a second or two at most. It's just there to reassure them that the app is, in fact, starting up. If they're seeing it for longer periods than that, your time is better spent optimizing your app's startup time, rather than prettifying it.

Community
  • 1
  • 1
Cody Gray
  • 222,280
  • 47
  • 466
  • 543