vb2008关闭消息框终于实现了,可以…

前端之家收集整理的这篇文章主要介绍了vb2008关闭消息框终于实现了,可以…前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
感谢不知名的网友提示
.net 和vb不一样。 窗口句柄之类的要声明称interger 32位的才行 如果在。net中 声明成long 那就执行不成功

 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal lpWindowName As String) As Integer
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer,ByVal wMsg As Integer,ByVal wParam As Integer,ByVal lParam As Integer) As Integer
-----------------------------------------------------------------------------
'以下是我的测试程序,form1窗体里放了个button1,点击button1弹出消息,定时程序,自动关闭消息框。
'接下来关闭网页弹出消息应该就没问题了。

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Call run_timer()
MsgBox("test")
End Sub
Sub Close_win()
Const WM_CLOSE = &H10
Dim hwnd As Long
hwnd = FindWindow("#32770","WindowsApplication1") ‘如果不知道窗体类,#32770,可以’用vbNullString 代替 ,可以用vs2008 的SPy++来查找类,"WindowsApplication1"是消息框的名称,自己灵活处理。
 If hwnd > 0 Then
 PostMessage(hwnd,WM_CLOSE,0&,0&)
 End If
 End Sub
 Sub run_timer()
 Dim mytimer As Timer = New Timer
 mytimer.Interval = 1000
 mytimer.Start()
 AddHandler mytimer.Tick,AddressOf Close_win
 End Sub
End Class
原文链接:https://www.f2er.com/vb/257109.html

猜你在找的VB相关文章