跳到主要内容

VB6启动窗口渐变效果

·

建立一个Timer1 即可实现启动窗口渐变效果

1Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal HWnd As Long, ByVal nIndex As Long) As Long
2Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal HWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
3Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal HWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
4Private Const WS_EX_LAYERED = &H80000
5Private Const GWL_EXSTYLE = (-20)
6Private Const LWA_ALPHA = &H2
7Private Const LWA_COLORKEY = &H1
 1Private Sub Form_Load()
 2SetWinAlpha 0
 3Timer1.Interval = 30
 4Timer1.Enabled = True
 5End Sub
 6 
 7Sub SetWinAlpha(a As Byte)
 8SetWindowLong Me.HWnd, GWL_EXSTYLE, GetWindowLong(Me.HWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
 9SetLayeredWindowAttributes Me.HWnd, 0, a, LWA_ALPHA
10End Sub
 1Private Sub Timer1_Timer()
 2Static a As Byte
 3If a >= 255 Then
 4    SetWinAlpha 255
 5    Timer1.Enabled = False
 6Else
 7    SetWinAlpha a
 8    a = a + 5
 9End If
10End Sub
白日映照满天星
作者
白日映照满天星
订阅我频道让你站在上帝角度观察视野! QQ:3925993 有尝解决技术问题【备注你的问题】 🐑

阅读量:评论:
赞赏码图