LVM_GETITEM for Listviews does not work !

260 views
Skip to first unread message

bmw_m3

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

Hello,

I try to perform (SendMessage) the LVM_GETITEM message to a ListView
Control within another Application (Actually the ListView of Windows
Explorer), but the call returns FALSE all the time. The ListView handle
is correct, because I can perform a LVM_GETITEMCOUNT message and I get
the correct item count. If I perform the same call to one of my own
Delphi ListViews, it works fine.

Any ideas why this does not work ? Is there any difference when
accessing an external ListView (of type SysListView32) ? I would by glad
about any small example Delphi code or explanation of this "feature".

Any help greatly appreciated !

Thanks
Mike

PS: Please reply to my mail account, since checking this group is not
that easy for me.

Rudy Velthuis

unread,
Feb 22, 1998, 3:00:00 AM2/22/98
to

bmw_m3 schrieb in Nachricht <34ED80C0...@geocities.com>...


>Hello,
>
>I try to perform (SendMessage) the LVM_GETITEM message to a ListView
>Control within another Application (Actually the ListView of Windows
>Explorer), but the call returns FALSE all the time. The ListView
handle
>is correct, because I can perform a LVM_GETITEMCOUNT message and I
get
>the correct item count. If I perform the same call to one of my own
>Delphi ListViews, it works fine.
>
>Any ideas why this does not work ? Is there any difference when
>accessing an external ListView (of type SysListView32) ? I would by
glad
>about any small example Delphi code or explanation of this "feature".

I did something like this in a test application. This worked:

type
PInfo = ^TInfo;
TInfo = packed record
Point: TPoint;
Text: array[0..255] of Char;
Item: TLVItem;
FindInfo: TLVFindInfo;
end;

...

procedure TMainForm.SaveItemClick(Sender: TObject);
var
Info: PInfo;
Wnd: HWnd;
Count, I: Integer;
SharedMem: TSharedMem;
begin
// ...
Wnd := FindWindowEx(Wnd, 0, 'SysListView32', nil);
Count := ListView_GetItemCount(Wnd);

// SharedMem comes from unit IPCThrd, somewhere in the Delphi demos.

SharedMem := TSharedMem.Create('', SizeOf(TInfo));

Info := SharedMem.Buffer;
with Info^ do
try
Item.pszText := Info^.Text;
Item.cchTextMax := 255;
Item.mask := LVIF_TEXT;
for I := 0 to Count - 1 do
begin
Item.iItem := I;
ListView_GetItem(Wnd, Item);
ListView_GetItemPosition(Wnd, I, Point);
HandleItem(Info);
end;
finally
SharedMem.Free;
end;
end;


I have cut out some unimportant parts, but I think you'll get the
idea.

--
Rudy Velthuis
--------------------------------------------------------
. Member of the JEDI Project
. Gladbeck, NRW Germany
. E-Mail: rvelthuis at cww dot de
--------------------------------------------------------


Reply all
Reply to author
Forward
0 new messages