# alpha-transparent splash screen in win32

## 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 on other sites
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 = &H80000Private 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 LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate 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_ALPHAEnd 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).