|
Option Explicit
Public Declare Function DeleteObject Lib "GDI32" (ByVal hObject _
As Long) 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 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 Long) As Long
Public Declare Function ReleaseCapture Lib "User32" () As Long
Public Declare Function SendMessage Lib "User32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Long) As Long
Public Sub CreateSkin(ByVal fFORM As Form, pSKIN As PictureBox)
Dim lSkin As Long
fFORM.Hide
Screen.MousePointer = vbHourglass
With pSKIN
.Visible = False
.Left = 0
.Top = 0
.BorderStyle = 0
.AutoRedraw = True
.AutoSize = True
End With
With fFORM
.Width = pSKIN.Width
.Height = pSKIN.Height
.Picture = pSKIN.Picture
lSkin = RegionFromBitmap(pSKIN)
Call SetWindowRgn(.hWnd, lSkin, True)
End With
Screen.MousePointer = vbDefault
fFORM.Show
End Sub
Private Function RegionFromBitmap(pSKIN As PictureBox) As Long
Dim lHoch As Long, lBreit As Long
Dim lTemp As Long, lSkin As Long
Dim lStart As Long, lZeile As Long, lSpalte As Long
Dim lBackColor As Long
lSkin = CreateRectRgn(0, 0, 0, 0)
With pSKIN
lHoch = .Height / Screen.TwipsPerPixelY
lBreit = .Width / Screen.TwipsPerPixelX
lBackColor = GetPixel(.hDC, 0, 0)
For lZeile = 0 To lHoch - 1
lSpalte = 0
Do While lSpalte < lBreit
Do While lSpalte < lBreit And _
GetPixel(.hDC, lSpalte, lZeile) = lBackColor
lSpalte = lSpalte + 1
Loop
If lSpalte < lBreit Then
lStart = lSpalte
Do While lSpalte < lBreit And _
GetPixel(.hDC, lSpalte, lZeile) <> lBackColor
lSpalte = lSpalte + 1
Loop
If lSpalte > lBreit Then lSpalte = lBreit
lTemp = CreateRectRgn(lStart, lZeile, lSpalte, lZeile + 1)
Call CombineRgn(lSkin, lSkin, lTemp, 2)
Call DeleteObject(lTemp)
End If
Loop
Next
End With
RegionFromBitmap = lSkin
End Function
Public Sub MoveWindow(ByVal lHandle As Long)
ReleaseCapture
Call SendMessage(lHandle, &HA1, 2, 0)
End Sub
|
|