VB用API读取LISTBOX中的每一项的内容和项的总数.
VB用API读取LISTBOX中的每一项的内容到TEXTBOX中.在用API读取LISTBOX中的项的总数到LABEL中.null_vbt,铁血黄昏,我是读取别的软件的,...
VB用API读取LISTBOX中的每一项的内容到TEXTBOX中.
在用API读取LISTBOX中的项的总数到LABEL中.
null_vbt,铁血黄昏,我是读取别的软件的,不是VB本身.这里只是用VB本身做个实例. 展开
在用API读取LISTBOX中的项的总数到LABEL中.
null_vbt,铁血黄昏,我是读取别的软件的,不是VB本身.这里只是用VB本身做个实例. 展开
展开全部
我正好有原码:
使用很简单:
运行后将鼠标移到你要的窗口,如果是一个Listbox,它的内容将被复制到程序的List2控件。
展开全部
VB API读取LISTBOX
Private Const LB_GETTEXT = &H189
Private Const LB_GETCOUNT = &H18B
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Private Sub Command1_Click()
Dim i As Long
Dim count As Long
Dim s As String
Dim sztext As String
count = SendMessageBynum&(List1.hwnd, LB_GETCOUNT, 0&, 0&)
Label1.Caption = count
For i = 0 To count - 1
s = String$(255, 0)
SendMessageByString& List1.hwnd, LB_GETTEXT, i, s
s = Left$(s, InStr(1, s, Chr$(0)) - 1)
sztext = sztext & s & vbCrLf
Next i
Text1.Text = sztext
End Sub
Private Const LB_GETTEXT = &H189
Private Const LB_GETCOUNT = &H18B
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Private Sub Command1_Click()
Dim i As Long
Dim count As Long
Dim s As String
Dim sztext As String
count = SendMessageBynum&(List1.hwnd, LB_GETCOUNT, 0&, 0&)
Label1.Caption = count
For i = 0 To count - 1
s = String$(255, 0)
SendMessageByString& List1.hwnd, LB_GETTEXT, i, s
s = Left$(s, InStr(1, s, Chr$(0)) - 1)
sztext = sztext & s & vbCrLf
Next i
Text1.Text = sztext
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_GETCOUNT = &H18B
Private Sub Command1_Click()
Dim WinWnd As Long
WinWnd = FindWindow(vbNullString, "Form1") '#Form1是对方应用程序的标题
'MsgBox WinWnd
If WinWnd <> 0 Then
hWnd2 = FindWindowEx(WinWnd, 0, "ThunderRT6ListBox", vbNullString)
If hWnd2 Then
ItemCount = SendMessage(hWnd2, LB_GETCOUNT, 0, 0)
MsgBox ItemCount
End If
End If
End Sub
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_GETCOUNT = &H18B
Private Sub Command1_Click()
Dim WinWnd As Long
WinWnd = FindWindow(vbNullString, "Form1") '#Form1是对方应用程序的标题
'MsgBox WinWnd
If WinWnd <> 0 Then
hWnd2 = FindWindowEx(WinWnd, 0, "ThunderRT6ListBox", vbNullString)
If hWnd2 Then
ItemCount = SendMessage(hWnd2, LB_GETCOUNT, 0, 0)
MsgBox ItemCount
End If
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for i=0 to list1.listcount-1
list1.listindex=i
msgbox list1.text
next
没有必要API
list1.listindex=i
msgbox list1.text
next
没有必要API
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我的个神哪,,这么简单的问题还用API???
你这不是明摆着要把简单问题复杂化嘛 = =
自己看一下listbox控件的属性方法吧。
你这不是明摆着要把简单问题复杂化嘛 = =
自己看一下listbox控件的属性方法吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询