关于VB的渐变效果
来源:百度知道 编辑:UC知道 时间:2024/06/06 21:08:22
'淡入淡出必须用到API
Option Explicit
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 Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Sub 透明(ByVal hWnd As Long, Optional ByVal Color As Long = 0, Optional ByVal Diaphaneity As Long = -1)
SetWindowLong hWnd, -20, &H80000
If Diaphaneity < 0 Or Diaphaneity > 255 Then
SetLayeredWindowAttributes hWnd, ByVal Color, 0, 1
Else
SetLayeredWindowAttributes hWnd, 0, ByVal Diaphaneity, 2
End If
End Sub
Private Sub Form_Activate()
Static Flag As Boolean
Dim I As Long
If Flag Then Exit Sub
Do
透明 Me.hWnd, 0, I
Me.Refresh
I = IIf((I + 3 > 255) A