透明效果
作者:admin 日期:2008-06-21
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 SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20) ' 设置窗体的透明度
Private Const LWA_ALPHA = &H2
Private Sub Form_Activate()
On Error Resume Next
For i = 0 To 150 Step 2.5
SetLayeredWindowAttributes Me.hwnd, 0, i, LWA_ALPHA
DoEvents
Next i
End Sub
Private Sub Form_load()
Dim rtn As Long
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hwnd, 0, 0, LWA_ALPHA
End Sub
'引用自http://hi.baidu.com/%D3%EA%D6%AE%D3%A1%BC%C7/blog/item/2fa5d8ca45687f85c817683a.html
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 SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20) ' 设置窗体的透明度
Private Const LWA_ALPHA = &H2
Private Sub Form_Activate()
On Error Resume Next
For i = 0 To 150 Step 2.5
SetLayeredWindowAttributes Me.hwnd, 0, i, LWA_ALPHA
DoEvents
Next i
End Sub
Private Sub Form_load()
Dim rtn As Long
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hwnd, 0, 0, LWA_ALPHA
End Sub
'引用自http://hi.baidu.com/%D3%EA%D6%AE%D3%A1%BC%C7/blog/item/2fa5d8ca45687f85c817683a.html
评论: 0 | 引用: 0 | 查看次数: 1787
发表评论
你没有权限发表留言!