Vous connaissez tous le logiciel winamp ??? avec des skins transparent ?
Voici comment faire pareil , et très rapidement !!!
(y'a un exemple dasn le zip)
il faut:
- une picturebox(picture1) avec la l'image ke vous voulez dedans
Source / Exemple :
'----- DANS UNE FORM -----
Private Sub Form_Load()
Dim WindowRegion As Long
'Propriétés de la picture box
Picture1.AutoRedraw = True
Picture1.BorderStyle = 0
Picture1.ScaleMode = 3
'Position de la picture box
Picture1.Top = 0: Picture1.Left = 0
'"Découpe" la form suivant Picture1
WindowRegion = MakeRegion(Picture1)
SetWindowRgn Me.hWnd, WindowRegion, True
End Sub
'----- DANS UN MODULE -----
Public Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Const RGN_OR = 2
Public Function MakeRegion(picSkin As PictureBox) As Long
' faites une fenêtre "région" basée sur une picture de picture box
' Ceci ce fait en passant l'image pixel par pixel et en créant une
' région pour chaque pixel non transparent
' Le code est optimisé, il est donc assez rapide
Dim X As Long, Y As Long, StartLineX As Long
Dim FullRegion As Long, LineRegion As Long
Dim TransparentColor As Long
Dim InFirstRegion As Boolean
Dim InLine As Boolean
Dim hDC As Long
Dim PicWidth As Long
Dim PicHeight As Long
hDC = picSkin.hDC
PicWidth = picSkin.ScaleWidth
PicHeight = picSkin.ScaleHeight
InFirstRegion = True: InLine = False
X = Y = StartLineX = 0
' Ici, la couleur de transparence est basé sur le pixel en haut a gauche
' Mais vous pouvez mettre la couleur ke vous voulez
TransparentColor = GetPixel(hDC, 0, 0)
For Y = 0 To PicHeight - 1
For X = 0 To PicWidth - 1
If GetPixel(hDC, X, Y) = TransparentColor Or X = PicWidth Then
If InLine Then
InLine = False
LineRegion = CreateRectRgn(StartLineX, Y, X, Y + 1)
If InFirstRegion Then
FullRegion = LineRegion
InFirstRegion = False
Else
CombineRgn FullRegion, FullRegion, LineRegion, RGN_OR
DeleteObject LineRegion
End If
End If
Else
If Not InLine Then
InLine = True
StartLineX = X
End If
End If
Next
Next
MakeRegion = FullRegion
End Function
Conclusion :
Voila !
CE CODE N'EST PAS DE MOI:
Je l'ai trouvé a l'adresse suivante :
http://www.freevbcode.com/ShowCode.Asp?ID=1124
comme je l'ai pas trouvé avant sur ce site, g pensé utile de le rajouter
@+
fabs ;-)
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.