| |||||
| Dernière réponse | |
|---|---|
| Sujet : Skins et VB 6 ??? | |
| karlkox | Voici mon code perso :
'dans un .BAS 'Pour les regions Private Const RGN_DIFF = 4 Type POINTAPI X As Long Y As Long End Type 'utile pour les régions Type Coord X As Long Y As Long End Type 'Window Region declaration 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 Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Coord, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long Public Declare Function CreatePolyPolygonRgn Lib "gdi32" (lpPoint As Coord, lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long Dim CurRgn, TempRgn As Long ' Region variables Public Function AutoFormShape(bg As Form, transColor) Dim X, Y As Integer Dim success As Long CurRgn = CreateRectRgn(0, 0, bg.ScaleWidth, bg.ScaleHeight) While Y <= bg.ScaleHeight While X <= bg.ScaleWidth If GetPixel(bg.hdc, X, Y) = transColor Then TempRgn = CreateRectRgn(X, Y, X + 1, Y + 1) success = CombineRgn(CurRgn, CurRgn, TempRgn, RGN_DIFF) DeleteObject (TempRgn) End If X = X + 1 Wend Y = Y + 1 X = 0 Wend success = SetWindowRgn(bg.hwnd, CurRgn, True) DeleteObject (CurRgn) End Function 'Dans le form ' il suffit de charger une image pour sa forme (propriété picture 'ou avec loadpicture) et ensuite (ici le fond est violet), seule 'la couleur en parametre est supprimée. Private Sub Form_Load() AutoFormShape Me, RGB(255, 0, 255) End sub |
| Vue Rapide de la discussion |
|---|