karlkox | Code :
- 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
- Private Const RGN_DIFF = 4
- 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
- ' Utilisation (dans le form)
- ' Call AutoFormShape(Me, RGB(255, 0, 255))
|
|