你需要用到以下API
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal IParam As String) As Integer
Public Declare Function SendMessage2 Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal IParam As StringBuilder) As Integer
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal IpszClass As String, ByVal IpszWindow As String) As IntPtr
具体用途,请自行百度。
获取句柄不一定要用 FindWindow ,还可以枚举:
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDNEXT = 2
Private Sub Command1_Click()
Dim lngHwnd As Long, ret As Long
Dim s As String 255
Dim sName As String
lngHwnd = GetWindow(Mehwnd, GW_HWNDFIRST)
Do While lngHwnd
ret = GetWindowText(lngHwnd, s, 255)
sName = Blank(s)
If InStr(sName, "记事本") <> 0 Then '这里“记事本”替换成程序标题相同的部分
'这里写 将句柄加入数组的相关代码
End If
lngHwnd = GetWindow(lngHwnd, GW_HWNDNEXT)
Loop
End Sub
Public Function Blank(ByVal szString As String) As String
Dim l As Integer
l = InStr(szString, Chr(0))
If l > 0 Then
Blank = Left(szString, l - 1)
Else
Blank = szString
End If
End Function
以上就是关于Vb怎么获取下图对话框里的按钮句柄和文本框句柄发送消息用全部的内容,包括:Vb怎么获取下图对话框里的按钮句柄和文本框句柄发送消息用、vb如何获取到窗口的句柄、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)