Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey,

 

Is it possible take a 'screenshot' of the stuff that is behind of an partically form.

 

And then setting it as background, to get a 'fake' transparent effect?

 

(idea from: adobe splash screens)

  • Leaders
Posted

in a Class module ( or below the End Class statement of your Form ) ....

Public Class _win32

   Public Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal crKey As Integer, ByVal bAlpha As Byte, ByVal dwFlags As Integer) As Integer
   Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
   Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
   Public Const GWL_EXSTYLE As Integer = -20
   Public Const LWA_COLORKEY = &H1
   Public Const LWA_ALPHA = &H2
   Public Const WS_EX_LAYERED = &H80000
End Class

then in your Form ( in the Form_Load event ) ...

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.BackColor = Color.Snow '/// set the form's colour to a different colour than any control holds ( to prevent the controls dissappearing )

       Dim style As Integer = _win32.GetWindowLong(Me.Handle, _win32.GWL_EXSTYLE)
       style = style Or _win32.WS_EX_LAYERED
       _win32.SetWindowLong(Me.Handle, _win32.GWL_EXSTYLE, style)

       _win32.SetLayeredWindowAttributes(Me.Handle, ColorTranslator.ToWin32(Me.BackColor), 250, _win32.LWA_COLORKEY Or _win32.LWA_ALPHA)
   End Sub

Posted (edited)

OMG thx, thats exactly what i need

 

Now i'm gonna try understand all the code init :D

 

thx again

 

you are a god :)

Edited by Lemon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...