Home > Back-end >  How Delphi for external application listview, the currently selected lines of text information
How Delphi for external application listview, the currently selected lines of text information

Time:10-05

BBS has access to external application listview inside examples of full text information, but how to get external programs currently selected in the listview lines of text information?

CodePudding user response:

Can I take a message to the values, there are several related news, forget, just remember a LVM_GETITEMCOUNT access lines, just this clue search

CodePudding user response:

Yes, by ListView_GetItemCount (mHandle); Get the rows,
But how to get each line selected, please expert help,

CodePudding user response:

The following code is to get all of the text to the external listview can get normal, how to get a row is selected???????????????
USES CommCtrl;
The function ListViewColumnCount (mHandle: THandle) : Integer;
The begin
Result:=Header_GetItemCount (ListView_GetHeader (mHandle));
end; {ListViewColumnCount}
The function GetListViewText (mHandle: THandle; MStrings: TStrings) : Boolean;
Var
VColumnCount: Integer;
VItemCount: Integer;
I, J: Integer;
VBuffer: an array of Char [0.. 255];
VPRocessId: DWord;
VProcess: THandle;
VPointer: Pointer;
VNumberOfBytesRead: Cardinal;
S: a string;
VItem: TLVItem;
The begin
Result:=False;
If not Assigned (mStrings) then the Exit;
VColumnCount:=ListViewColumnCount (mHandle);
If vColumnCount & lt;=0 then the Exit;
VItemCount:=ListView_GetItemCount (mHandle);
GetWindowThreadProcessId (mHandle, @ vProcessId);
VProcess:=OpenProcess (PROCESS_VM_OperaTION or PROCESS_VM_READ or
PROCESS_VM_WRITE, False, vProcessId);
VPointer:=VirtualAllocEx (vProcess, nil, 4096, the MEM_RESERVE or MEM_COMMIT,
PAGE_READWRITE);
MStrings. BeginUpdate;
Try
MStrings. The Clear;
For I:=0 to do begin vItemCount - 1
S:=';
For J:=0 to do begin vColumnCount - 1
With vItem do begin
Mask:=LVIF_TEXT;
IItem:=I;
ISubItem:=J;
CchTextMax:=SizeOf (vBuffer);
PszText:=Pointer (Cardinal (vPointer) + SizeOf (TLVItem));
end;
WriteProcessMemory (vProcess vPointer, @ vItem,
SizeOf (TLVItem), vNumberOfBytesRead);
SendMessage (mHandle LVM_GETITEM, I, lparam (vPointer));
ReadProcessMemory (vProcess, Pointer (Cardinal (vPointer) + SizeOf (TLVItem)),
@ vBuffer [0], SizeOf (vBuffer), vNumberOfBytesRead);
S:=S + # 9 + vBuffer;
end;
Delete (S, 1, 1);
MStrings. Add (S);
end;
The finally
VirtualFreeEx (vProcess vPointer, 0, MEM_RELEASE);
The CloseHandle (vProcess);
MStrings. EndUpdate;
end;
Result:=True;
end; {GetListViewText}
//Example
Procedure TForm1. FormCreate (Sender: TObject);
The begin
RegisterHotKey (Handle, 1, MOD_WIN VK_F2);
end;
Procedure TForm1. FormDestroy (Sender: TObject);
The begin
UnRegisterHotKey (Handle, 1);
end;
Procedure TForm1. WMHOTKEY (var Msg: TWMHOTKEY);
The begin
Case Msg. The HotKey of
1:
GetListViewText (
WindowFromPoint (Point (Mouse) CursorPos) X, Mouse. CursorPos. Y)),
MemoText. Lines);
end;
end;

CodePudding user response:

Refer to
The function TCustomListView. GetSelected: TListItem;
And
The function TCustomListView. GetNextItem (StartItem: TListItem;
Direction: TSearchDirection; States: TItemStates) : TListItem;

These two methods of implementation code
  • Related