home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1999 April / CD_Shareware_Magazine_31.iso / Free / Prg / API23.exe / module1.bas < prev    next >
Encoding:
BASIC Source File  |  1998-12-07  |  2.5 KB  |  67 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. 'Pon esto en un modulo
  5. Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long
  6. Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long
  7. Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
  8. Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  9. Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
  10. Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
  11.  
  12. Public Const RGN_AND = 1
  13. Public Const RGN_COPY = 5
  14. Public Const RGN_DIFF = 4
  15. Public Const RGN_OR = 2
  16. Public Const RGN_XOR = 3
  17.  
  18. Type POINTAPI
  19.     x As Long
  20.     Y As Long
  21. End Type
  22.  
  23. Type RECT
  24.     Left As Long
  25.     Top As Long
  26.     Right As Long
  27.     Bottom As Long
  28. End Type
  29. Public Sub MakeTransparent(frm As Form)
  30.  
  31.     'This code was takin from a AOL Visual Basic
  32.     'Message Board. It was submited by: SOOPRcow
  33.     Dim rctClient As RECT, rctFrame As RECT
  34.     Dim hClient As Long, hFrame As Long
  35.     '// Grab client area and frame area
  36.     GetWindowRect frm.hWnd, rctFrame
  37.     GetClientRect frm.hWnd, rctClient
  38.     '// Convert client coordinates to screen coordinates
  39.     Dim lpTL As POINTAPI, lpBR As POINTAPI
  40.     lpTL.x = rctFrame.Left
  41.     lpTL.Y = rctFrame.Top
  42.     lpBR.x = rctFrame.Right
  43.     lpBR.Y = rctFrame.Bottom
  44.     ScreenToClient frm.hWnd, lpTL
  45.     ScreenToClient frm.hWnd, lpBR
  46.     rctFrame.Left = lpTL.x
  47.     rctFrame.Top = lpTL.Y
  48.     rctFrame.Right = lpBR.x
  49.     rctFrame.Bottom = lpBR.Y
  50.     rctClient.Left = Abs(rctFrame.Left)
  51.     rctClient.Top = Abs(rctFrame.Top)
  52.     rctClient.Right = rctClient.Right + Abs(rctFrame.Left)
  53.     rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)
  54.     rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)
  55.     rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)
  56.     rctFrame.Top = 0
  57.     rctFrame.Left = 0
  58.     '// Convert RECT structures to region handles
  59.     hClient = CreateRectRgn(rctClient.Left, rctClient.Top, rctClient.Right, rctClient.Bottom)
  60.     hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, rctFrame.Right, rctFrame.Bottom)
  61.     '// Create the new "Transparent" region
  62.     CombineRgn hFrame, hClient, hFrame, RGN_XOR
  63.     '// Now lock the window's area to this created region
  64.     SetWindowRgn frm.hWnd, hFrame, True
  65.     
  66. End Sub
  67.