vb.net 定时关闭messagebox
1个回答
2010-10-25
展开全部
.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
声明完后
Me.Timer1.Enabled = True
Me.Timer1.Interval = 10000
MessageBox.Show("xinjing", "haha")
Timer1.Enabled = False
在timer的tick中
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim hWnd As Integer
hWnd = FindWindow(vbNullString, "haha")
If hWnd Then
'查找到窗口则关闭
PostMessage(hWnd, &H10, 0&, 0&)
End If
End Sub
就可解觉问题
纯粹自问自答 在网上找了好久也没找到 最后自己摸索下 就记在这儿了
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
声明完后
Me.Timer1.Enabled = True
Me.Timer1.Interval = 10000
MessageBox.Show("xinjing", "haha")
Timer1.Enabled = False
在timer的tick中
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim hWnd As Integer
hWnd = FindWindow(vbNullString, "haha")
If hWnd Then
'查找到窗口则关闭
PostMessage(hWnd, &H10, 0&, 0&)
End If
End Sub
就可解觉问题
纯粹自问自答 在网上找了好久也没找到 最后自己摸索下 就记在这儿了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询