用VB写一个小程序,要求运行后倒计时2小时自动弹出对话框,上面写着“测试成功!”,此时禁止任何操作。
要求:1.运行后程序隐藏(忽视进程),计算机正常使用。2.运行后自动倒计时,2小时后自动弹出对话框“测试成功!”。且此时禁止任何操作,只能关机。。...
要求:
1.运行后程序隐藏(忽视进程),计算机正常使用。
2.运行后自动倒计时,2小时后自动弹出对话框“测试成功!”。且此时禁止任何操作,只能关机。。 展开
1.运行后程序隐藏(忽视进程),计算机正常使用。
2.运行后自动倒计时,2小时后自动弹出对话框“测试成功!”。且此时禁止任何操作,只能关机。。 展开
1个回答
展开全部
创建一个窗体,画两个计时器,一个按钮,一个文本框。把窗体的BORDERSTYLE设为0-NONE,其它属性均取默认值。然后输入以下代码
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT As Long = &H20&
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 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Sub Form_Load()
Dim ret As Long
ret = GetWindowLong(hwnd, GWL_EXSTYLE)
ret = ret Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetWindowLong hwnd, GWL_EXSTYLE, ret
SetLayeredWindowAttributes hwnd, 0, 250, LWA_ALPHA
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
Form1.Hide
Text1.Text = 7200
Timer1.Interval = 1000
Command1.Visible = False
Text1.Visible = False
End Sub
Private Sub Timer1_Timer()
Text1 = Text1 - 1
If Text1 = 0 Then
Me.Move 0, 0, Screen.Width, Screen.Height
Me.Show
MsgBox "测试成功!"
End If
Command1.Value = True
End Sub
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT As Long = &H20&
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 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Sub Form_Load()
Dim ret As Long
ret = GetWindowLong(hwnd, GWL_EXSTYLE)
ret = ret Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetWindowLong hwnd, GWL_EXSTYLE, ret
SetLayeredWindowAttributes hwnd, 0, 250, LWA_ALPHA
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
Form1.Hide
Text1.Text = 7200
Timer1.Interval = 1000
Command1.Visible = False
Text1.Visible = False
End Sub
Private Sub Timer1_Timer()
Text1 = Text1 - 1
If Text1 = 0 Then
Me.Move 0, 0, Screen.Width, Screen.Height
Me.Show
MsgBox "测试成功!"
End If
Command1.Value = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |