Merrion
06-10-2002, 10:32 AM
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const WS_EX_TRANSPARENT = &H20&
Private Const GWL_EXSTYLE = (-20)
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Const TRANSPARENT = 1
Private Declare Function InvalidateRectLong Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long
Public Sub MakeFrameTransparent(ByVal fraThis As Control)
Dim lExStyle As Long
lExStyle = GetWindowLong(fraThis.hwnd, GWL_EXSTYLE)
lExStyle = lExStyle Or WS_EX_TRANSPARENT
'\\ Set window style to be transparent
Call SetWindowLong(fraThis.hwnd, GWL_EXSTYLE, lExStyle)
'\\ make the fram backstyle transparent
Call SetBkMode(GetDC(fraThis.hwnd), TRANSPARENT)
'\\ Make frame window redraw itself
Call SetWindowPos(fraThis.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED)
Call InvalidateRectLong(fraThis.hwnd, vbNull, True)
End Sub
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const WS_EX_TRANSPARENT = &H20&
Private Const GWL_EXSTYLE = (-20)
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Const TRANSPARENT = 1
Private Declare Function InvalidateRectLong Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long
Public Sub MakeFrameTransparent(ByVal fraThis As Control)
Dim lExStyle As Long
lExStyle = GetWindowLong(fraThis.hwnd, GWL_EXSTYLE)
lExStyle = lExStyle Or WS_EX_TRANSPARENT
'\\ Set window style to be transparent
Call SetWindowLong(fraThis.hwnd, GWL_EXSTYLE, lExStyle)
'\\ make the fram backstyle transparent
Call SetBkMode(GetDC(fraThis.hwnd), TRANSPARENT)
'\\ Make frame window redraw itself
Call SetWindowPos(fraThis.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED)
Call InvalidateRectLong(fraThis.hwnd, vbNull, True)
End Sub