Form transparent machen
[Windows 95/98/NT]

02.02.1999


So geht's:
ERFORDERLICHE OBJEKTE:

-- keine --


FORM-CODE

Private Declare Function GetWindowRect Lib "user32" _
   (ByVal hWnd As Long, lpRECT As RECT) As Long
Private Declare Function GetClientRect Lib "user32" _
   (ByVal hWnd As Long, lpRECT As RECT) As Long
Private Declare Function CombineRgn Lib "gdi32" _
   (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal _
   hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" _
   (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, _
   ByVal Y2 As Long) As Long
Private Declare Function ScreenToClient Lib "user32" _
   (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetWindowRgn Lib "user32" _
   (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw _
   As Boolean) As Long

Private Type POINTAPI
   x As Long
   Y As Long
End Type

Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type


Private Sub Transparent()
   Dim rctClient As RECT, rctFrame As RECT
   Dim hClient As Long, hFrame As Long

   GetWindowRect Form1.hWnd, rctFrame
   GetClientRect Form1.hWnd, rctClient

   Dim lpTL As POINTAPI, lpBR As POINTAPI
   lpTL.x = rctFrame.Left
   lpTL.Y = rctFrame.Top
   lpBR.x = rctFrame.Right
   lpBR.Y = rctFrame.Bottom

   ScreenToClient Form1.hWnd, lpTL
   ScreenToClient Form1.hWnd, lpBR

   rctFrame.Left = lpTL.x
   rctFrame.Top = lpTL.Y
   rctFrame.Right = lpBR.x
   rctFrame.Bottom = lpBR.Y
   rctClient.Left = Abs(rctFrame.Left)
   rctClient.Top = Abs(rctFrame.Top)
   rctClient.Right = rctClient.Right + Abs(rctFrame.Left)
   rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)
   rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)
   rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)
   rctFrame.Top = 0
   rctFrame.Left = 0
   hClient = CreateRectRgn(rctClient.Left, rctClient.Top, _
      rctClient.Right, rctClient.Bottom)
   hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, _
      rctFrame.Right, rctFrame.Bottom)

   CombineRgn hFrame, hClient, hFrame, 3
   SetWindowRgn Form1.hWnd, hFrame, True
End Sub

Private Sub Form_Load()
   Transparent
End Sub


 

Download - 2 KB