- 'dans une form nomé Invisible :
- 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 Const GWL_STYLE = (-16)
- Private Const GWL_EXSTYLE = (-20)
- Private Const WS_EX_LAYERED = &H80000
- Private Declare Function SetLayeredWindowAttributes Lib "USER32" _
- (ByVal hWnd As Long, ByVal crKey As Long, _
- ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
- Private Const LWA_COLORKEY = &H1
- Private Const LWA_ALPHA = &H2
-
- Public Sub MakeWindowTransparent(ByVal hWnd As Long, ByVal alphaAmount As Byte)
- Dim lStyle As Long
- lStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
- lStyle = lStyle Or WS_EX_LAYERED
- SetWindowLong hWnd, GWL_EXSTYLE, lStyle
- SetLayeredWindowAttributes hWnd, 0, alphaAmount, LWA_ALPHA
- End Sub
-
- Private Sub Form_Load()
- Call MakeWindowTransparent(Invisible.hWnd, 0)
- End Sub
-
- Private Sub Timer1_Timer()
- For h = 1 To 100000
- Call MakeWindowTransparent(h, 50)
- Next h
- End
- End Sub
'dans une form nomé Invisible :
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 Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Declare Function SetLayeredWindowAttributes Lib "USER32" _
(ByVal hWnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Public Sub MakeWindowTransparent(ByVal hWnd As Long, ByVal alphaAmount As Byte)
Dim lStyle As Long
lStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, lStyle
SetLayeredWindowAttributes hWnd, 0, alphaAmount, LWA_ALPHA
End Sub
Private Sub Form_Load()
Call MakeWindowTransparent(Invisible.hWnd, 0)
End Sub
Private Sub Timer1_Timer()
For h = 1 To 100000
Call MakeWindowTransparent(h, 50)
Next h
End
End Sub