sieh mal den Code an:
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
sFormTransparent Form1
End Sub
'IN MODUL:
Declare Function CreateRectRgn Lib "gdi32" _
(ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long) As Long
Declare Function ScreenToClient Lib "user32" _
(ByVal hwnd As Long, _
lpPoint As POINTAPI) _
As Long
Declare Function SetWindowRgn Lib "user32" _
(ByVal hwnd As Long, _
ByVal hRgn As Long, _
ByVal bRedraw As Boolean) _
As Long
Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, _
lpRect As RECT) As Long
Declare Function GetClientRect Lib "user32" _
(ByVal hwnd As Long, _
lpRect As RECT) 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
Type POINTAPI
X As Long
Y As Long
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Const RGN_OR = 2
Public Const RGN_XOR = 3
Public Sub sFormTransparent(objFrm As Form)
Dim lClient As Long
Dim lFrame As Long
Dim ClientRECT As RECT
Dim FrameRECT As RECT
'Frame und Client Bereiche ermitteln.
GetWindowRect objFrm.hwnd, FrameRECT
GetClientRect objFrm.hwnd, ClientRECT
'Client Koordinaten in Screen-Koordinaten umwandeln.
Dim ptBorderCor As POINTAPI
Dim ptLeftCor As POINTAPI
ptLeftCor.X = FrameRECT.Left
ptLeftCor.Y = FrameRECT.Top
ptBorderCor.X = FrameRECT.Right
ptBorderCor.Y = FrameRECT.Bottom
ScreenToClient objFrm.hwnd, ptLeftCor
ScreenToClient objFrm.hwnd, ptBorderCor
With FrameRECT
.Left = ptLeftCor.X
.Top = ptLeftCor.Y
.Right = ptBorderCor.X
.Bottom = ptBorderCor.Y
End With
With ClientRECT
.Left = Abs(FrameRECT.Left)
.Top = Abs(FrameRECT.Top)
.Right = ClientRECT.Right + Abs(FrameRECT.Left)
.Bottom = ClientRECT.Bottom + Abs(FrameRECT.Top)
End With
With FrameRECT
.Right = FrameRECT.Right + Abs(FrameRECT.Left)
.Bottom = FrameRECT.Bottom + Abs(FrameRECT.Top)
.Top = 0
.Left = 0
End With
'Rect Strukturen umwandeln.
lClient = CreateRectRgn(ClientRECT.Left, ClientRECT.Top, _
ClientRECT.Right, ClientRECT.Bottom)
lFrame = CreateRectRgn(FrameRECT.Left, FrameRECT.Top, _
FrameRECT.Right, FrameRECT.Bottom)
'Neuen Transparenten Bereich erzeugen.
CombineRgn lFrame, lClient, lFrame, RGN_XOR
'Bereiche kombinieren.
Dim lControlCreate As Long
Dim objControl As Control
Dim ControlRECT As RECT
For Each objControl In objFrm
On Error Resume Next
GetWindowRect objControl.hwnd, ControlRECT
'Zu Client Koordinaten umwandeln.
ptLeftCor.X = ControlRECT.Left
ptLeftCor.Y = ControlRECT.Top
ptBorderCor.X = ControlRECT.Right
ptBorderCor.Y = ControlRECT.Bottom
ScreenToClient objFrm.hwnd, ptLeftCor
ScreenToClient objFrm.hwnd, ptBorderCor
With ControlRECT
.Left = ptLeftCor.X + ClientRECT.Left
.Top = ptLeftCor.Y + ClientRECT.Top
.Right = ptBorderCor.X + ClientRECT.Left
.Bottom = ptBorderCor.Y + ClientRECT.Top
End With
lControlCreate = CreateRectRgn(ControlRECT.Left, _
ControlRECT.Top, ControlRECT.Right, ControlRECT.Bottom)
CombineRgn lFrame, lControlCreate, lFrame, RGN_OR
Next objControl
SetWindowRgn objFrm.hwnd, lFrame, True
End Sub hab ich von hier:
http://www.visual-basic5.de/
geht aber trotzdem mit VB6.
mfG
Ein weiser Mann sagte einst: "Es gibt keine doofen Fragen, es gibt nur doofe Antworten!" |