发消息选中syslistview32控件的ITEM
我要发送消息使另外一个进程窗口的SysListView32控件的一个item被选中
LVM_SETITEMSTATE这个怎么用??
endMessage hwn, LVM_SETITEMSTATE, 3, 0& ???
[解决办法]
Public Sub ListView_ItemSelect(ByVal hWnd As Long, Optional ByVal iItem As Long = 0)
Dim dwProcessId As Long
Dim hProcess As Long
Dim plvItem As Long
Dim LVITEM As LV_ITEMA
GetWindowThreadProcessId hWnd, dwProcessId '获取与指定窗口关联在一起的一个进程和线程标识符
'' hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, dwProcessId) '打开一个现有进程的句柄
hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, dwProcessId)
If hProcess Then
plvItem = VirtualAllocEx(hProcess, ByVal 0, LenB(LVITEM), MEM_COMMIT, PAGE_READWRITE) '分配内存
If plvItem Then
LVITEM.state = LVIS_SELECTED Or LVIS_FOCUSED Or LVIS_ACTIVATING
'lvItem.state = LVIS_SELECTED
LVITEM.stateMask = LVIS_SELECTED
Call WriteProcessMemory(hProcess, ByVal plvItem, LVITEM, LenB(LVITEM), 0) '写入内存
Dim t As Long
t = SendMessage(hWnd, LVM_SETITEMSTATE, iItem, ByVal plvItem)
'' MsgBox t
Call VirtualFreeEx(hProcess, ByVal plvItem, 0, MEM_RELEASE)
End If
Call CloseHandle(hProcess)
End If
End Sub