看到VB。NET有个窗体的透明效果的,虽然安装了.Net,
我是新手~NET好比VB6难好多~VB6也能做做这个效果~
斑竹好吓人哦~说了so-so拉~
这个好象到2K以上的系统才能看到哦。
代码:
FORM添加一个timer就可以了,in属性设置成5 (这个可以调节显示速度)
’------------------------------------------------------------------------------------------------------------------------
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 Const LWA_COLORKEY = &H1
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
Dim Color, Mid As Integer
Private Sub Form_Load()
Dim rtn As Long
Color = 5 ’初始化透明度
Mid = 5 ’透明度为5的差值减弱
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE) '取的窗口原先的样式
rtn = rtn Or WS_EX_LAYERED '使窗体添加上新的样式WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn '把新的样式赋给窗体
SetLayeredWindowAttributes Me.hwnd, 0, 0, LWA_ALPHA
'把窗体设置成半透明样式,第二个参数表示透明程度
'取值范围0--255,为0时就是一个全透明的窗体了
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1 = True
Mid = -5 ’透明度为5的差值增强
Cancel = True ’不能直接关闭程序
End Sub
Private Sub Timer1_Timer()
Color = Color + Mid ’改变透明程度
Select Case Color
Case 0 ’Color减到0时退出程序。
End
Case 5 To 254 ’逐渐变透明或不透明
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hwnd, 0, Color, LWA_ALPHA
Case 255 ’Color到255停止
Timer1 = False
End Select
End Sub