在VB中,让一个打开的窗体慢慢的消失(也就是缓缓的自动关闭),该如何写代码?
在VB中,让一个打开的窗体慢慢的消失(也就是缓缓的自动关闭),该如何写代码?
[解决办法]
不知道,你是不是要这样实现:
'窗体代码
'添加一个Timer,
Dim abc As Byte
Private Sub Form_Load()
DisAlpha Form1, 0
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
If abc > = 250 Then Exit Sub: Timer1.Enabled = False
abc = Val(abc) + Val(10)
DisAlpha Me, abc
End Sub
'标准模块代码
Option Explicit
Public Declare Function GetWindowLong Lib "user32 " Alias "GetWindowLongA " (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32 " Alias "SetWindowLongA " (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32 " (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Const LWA_ALPHA = &H2
Public Const LWA_COLORKEY = &H1
Public Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Sub DisAlpha(frmName As Form, intDx As Byte)
Dim rtn As Long
rtn = GetWindowLong(frmName.hWnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong frmName.hWnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes frmName.hWnd, 0, intDx, LWA_ALPHA
End Sub
---------
通过设置半透明渐显来实现,不知是你要的目的不?
在VB中,让一个打开的窗体慢慢的消失(也就是缓缓的自动关闭),该怎么写代码
在VB中,让一个打开的窗体慢慢的消失(也就是缓缓的自动关闭),该如何写代码?在VB中,让一个打开的窗体慢慢的
