Jump to content
  • Advertisement
Sign in to follow this  
yckx

alpha-transparent splash screen in win32

This topic is 3993 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

I'm trying to create an alpha-transparent splash screen, similar to what's used in Code::Blocks, using alpha values from the splash image. I'd provide a pic, but the screen capture seems to be delayed until the splash closes. I've looked around and found SetLayeredWindowAttributes, but it only uses colorkey transparency, and a single alpha value for the entire window. So I've decided I'm going to have to capture the screen region behind the splash window and manually blend it with the splash image. The problem is that my search-fu is failing me, and I can't find any info on how to capture the region I need. Help in this regard would be appreciated ;)

Share this post


Link to post
Share on other sites
Advertisement
I'm a VB6'er, but this should be easy enough to read even if you've never used VB6:

Private Const GWL_EXstyle = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20&
Private Const LWA_ALPHA = &H2&

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Sub Form_Load()
Dim Ret As Long
Ret = GetWindowLong(Me.hwnd, GWL_EXstyle)
SetWindowLong Me.hwnd, GWL_EXstyle, Ret Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, 150, LWA_ALPHA
End Sub


Me.hWnd is the handle of the form you wish to set translucent and 150 is your alpha value (on a scale of 255 and 0, where 255 is opaque, 0 is transparent).

Windows 2k/XP only (and probably Vista).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!