Form Invisible

cs_AngeloVivaldi Messages postés 60 Date d'inscription dimanche 8 décembre 2002 Statut Membre Dernière intervention 1 juillet 2004 - 30 nov. 2003 à 18:56
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 - 30 nov. 2003 à 19:31
Salut a tous

Voila, j'ai mis une image gif sur une form, le fond étan transparant, on voit la form ce qui n'est pa tres esthétique avec mon image =( j'ai utlisé le control image (pas le picturebox).

Mon problem es que je voudrai faire disparaitre la form (enfin la rendre tansparente) pour laisser ke l'image.

Merci d'avance pour vos aides =)

2 réponses

cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
30 nov. 2003 à 19:16
Regarde a fenetre transparente, il y a plein de sources qui parle de ça j'ai pas lien exact mais si tu creuse un peu tu va trouver.

Il faut utiliser SetWindowRgn avec quelque API GDI !

Option Explicit

Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Const RGN_OR = 2

Public Function MakeRegion(PictBox As PictureBox, ByVal X1 As Long, ByVal Y1 As Long, ByVal W1 As Long, ByVal H1 As Long) As Long
Dim TransparentColor As Long
Dim InFirstRegion As Boolean
Dim StartLineX As Long
Dim FullRegion As Long
Dim LineRegion As Long
Dim InLine As Boolean
Dim PicHeight As Long
Dim PicWidth As Long
Dim hDC As Long
Dim X As Long
Dim Y As Long

hDC = PictBox.hDC
PicWidth = PictBox.ScaleWidth
PicHeight = PictBox.ScaleHeight
'X Y StartLineX = 0
InFirstRegion = True
InLine = False

TransparentColor = GetPixel(hDC, 0, 0)

For Y = 0 To H1 'PicHeight - 1
For X = 0 To W1 'PicWidth - 1
'If GetPixel(hDC, X + X1, Y + Y1) TransparentColor Or X PicWidth Then If GetPixel(hDC, X + X1, Y + Y1) TransparentColor Or X W1 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

puis dans form_Load

WindowRegion = MakeRegion(Picture1, mAnim * 24, mDir * 32, 24, 32)
BitBlt Me.hDC, 0, 0, 24, 32, Picture1.hDC, mAnim * 24, mDir * 32, vbSrcCopy
SetWindowRgn hwnd, WindowRegion, True

@+

E.B.
0
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
30 nov. 2003 à 19:31
Va voir ma source nommée Horloge système 1.0 pour avoir un exemple concret de découpage de feuille à partir d'une image quelconque.

DarK Sidious

[Responsable de la rubrique API et responsable VB du site www.ProgOtoP.com]
0
Rejoignez-nous