Posted on 2005-05-14
Last Modified: 2012-05-05
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

Question by:Thor371
    LVL 11

    Accepted Solution

      wnd : cardinal;
      txt : pchar;
    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
    if wnd > 0 then SendMessage(wnd, lvm_deleteallitems, 0, 0);

    Author Comment

    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;
      plvfi: TLVFindInfo;
      result := false;
      plvfi.flags := LVFI_STRING or LVFI_PARTIAL;
      plvfi.psz := Caption;
    if ( ListView_FindItem(hdl, -1, plvfi) <> -1 ) then result := true

    LVL 11

    Expert Comment

    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?

    Author Comment

    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++ maybe thats answer to help me?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now