[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 641
  • Last Modified:

Listview DELETEALLITEMS

I'm wondeirng how I sendmessage to a listview in another program and delete all its items from my program.
I think i'm suppoed to use SendMessage(handle, lvm_DELETEALLITEMS

Thor371
0
Thor371
Asked:
Thor371
  • 2
  • 2
1 Solution
 
ZhaawZSoftware DeveloperCommented:
var
  wnd : cardinal;
  txt : pchar;
begin
wnd := FindWindow('TForm1', 'Form1');
wnd := GetWindow(wnd, gw_child);
GetMem(txt, 128);
while true do begin
  if wnd = 0 then break; // no more child controls
  GetClassName(wnd, txt, 128);
  if lstrcmp('TListView', txt) = 0 then break; // found ListView control
  wnd := GetWindow(wnd, gw_hwndnext); // get next child control
end;
FreeMem(txt);
if wnd > 0 then SendMessage(wnd, lvm_deleteallitems, 0, 0);
0
 
Thor371Author Commented:
thanks ZhaawZ for answer =)

You get all the points! If you can help me fix a function I wrote I'll give you another 2000 points

I'll open another thread and award you the points since it is a different question.
 
Function FindItem(hdl : THandle; Caption : PChar): bool;
var
  plvfi: TLVFindInfo;
begin
  result := false;
  plvfi.flags := LVFI_STRING or LVFI_PARTIAL;
  plvfi.psz := Caption;
if ( ListView_FindItem(hdl, -1, plvfi) <> -1 ) then result := true
end;

Thor371
0
 
ZhaawZSoftware DeveloperCommented:
Well, the only thing I can say about your function - you may write at the end of function
result := ListView_FindItem(hdl, -1, plvfi) <> -1;
and 'result := false;' is not needed in this case.

This functions will work only if listview is in the same application with this function. Do you need to work with listviews from external applications?
0
 
Thor371Author Commented:
Yeah it's an external program, not my process. It's actually an irc client that uses a listview class. The only thing i can think is to inject dll into process or use readprocessmemory to find items. I saw an example in c++ http://dotnetjunkies.com/WebLog/chris.taylor/archive/2004/01/16/5689.aspx maybe thats answer to help me?

Thor371
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now