Form transparente

Description

Voila une Form rendu transparente grâce à une capture d'écran projetée en
background : bon, c'est un peu boeuf mais ca marche...

Enjoy it.

ps : merci au forum pour le code sur la capture d'écran.

pps : j'ai rajouté une capture d'écran

Source / Exemple :


Option Explicit

Dim prevX As Single
Dim prevY As Single
Dim bLock As Boolean
Dim iCount As Integer

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Capture(Optional withVisible As Boolean = False)
     bLock = True
    
    prevX = Me.Left
    prevY = Me.Top
    
    If withVisible Then Me.Visible = False
    DoEvents
    Clipboard.Clear
    Call keybd_event(vbKeySnapshot, 1, 0, 0)
    While Not Clipboard.GetFormat(vbCFBitmap)
        DoEvents
    Wend
    Picture1.Picture = Clipboard.GetData(vbCFBitmap)
    
    If withVisible Then Me.Visible = True
    Me.Left = prevX
    Me.Top = prevY
    
    Clipboard.Clear
    
     bLock = False
End Sub

Private Sub Command1_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Call Capture(True)
    Call RefreshBackGround
End Sub

Private Sub RefreshBackGround()
     bLock = True
     
    prevX = Me.Left
    prevY = Me.Top
    
    Picture1.Width = prevX + Me.Width + 100
    Picture1.Height = prevY + Me.Height + 100
    Picture1.Top = -prevY - 330
    Picture1.Left = -prevX - 90
    
     bLock = False
End Sub

Private Sub Timer1_Timer()
    If bLock Then Exit Sub
    If Me.Left <> prevX Or Me.Top <> prevY Then
        RefreshBackGround
    Else
        iCount = iCount + 1
        If iCount > 3 Then
            iCount = 0
            Call Capture
        End If
    End If
End Sub

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.