某行获取焦点 procedure SetListViewIndex(mHandle: THandle; mIndex: Integer); var vProcessId: DWORD; vProcess: THandle; vPointer: Pointer; vNumberOfBytesRead: Cardinal; vItem: TLVItem; begin GetWindowThreadProcessId(mHandle, @vProcessId); vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, False, vProcessId); vPointer := VirtualAllocEx(vProcess, nil, 4096, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE); try vItem.stateMask := LVIS_FOCUSED + LVIS_SELECTED; vItem.state := LVIS_FOCUSED + LVIS_SELECTED; WriteProcessMemory(vProcess, vPointer, @vItem, SizeOf(TLVItem), vNumberOfBytesRead); SendMessage(mHandle, LVM_SETITEMSTATE, mIndex, lparam(vPointer)); finally VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE); CloseHandle(vProcess); end; end;