Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Aug : Unable to retrieve text from List View Item

www.cryer.info
Managed Newsgroup Archive

Unable to retrieve text from List View Item

Subject:Unable to retrieve text from List View Item
Posted by:"Glenn Laderer" (glader..@adelphia.net)
Date:30 Aug 2005 09:07:31 -0700

I am writing a program to control another program for work.
I am reading values from ComboBox lists and able to change the
entry that is selected.
I need to get the values of items in a listview and I am unable
to do it. I can get the count of items but I am unable to get
the text. I use the following code:

procedure List_ListView_Items(hListView: THandle; const Window: PWindowInfo = nil);
var ItemCount: Integer;
    Index: Integer;
    Mask: UINT;
    LVDisp: LV_DISPINFO;
    ListStr: String;
    Temp: Array [0..MAX_PATH] of Char;
begin
{$IFDEF Logging}
  Check_File_Open;
  if Assigned(Window) then Write_Window_Info(Window);
  ItemCount := ListView_GetItemCount(hListView);
  Writeln(TF, 'ItemCount = ', ItemCount);
  ItemCount := ItemCount - 1;
  if (ItemCount >= 0) and (ItemCount < ccMaxDisplayItems) then begin
    Mask := ListView_GetCallbackMask(hListView);
    Writeln(TF, 'Mask = ', Mask);
    Index := -1;
    Repeat
      Index := ListView_GetNextItem(hListView, Index, LVNI_ALL);
      if (Index <> -1) then begin
        ItemCount := ItemCount - 1;
        FillChar(Temp, Sizeof(Temp), 0);
        FillChar(LVDisp, Sizeof(LVDisp), 0);
        with LVDisp do
          with hdr, item do begin
            mask := LVIF_TEXT;
            iItem := Index;
            iSubItem := 0;
            pszText := Temp;
            cchTextMax := Sizeof(Temp) - 1;
            hwndFrom := hListView;
            code := LVN_GETDISPINFO;
            idFrom := hListView;
          end;
        SendMessage(GetParent(hListView), WM_NOTIFY, hListView, Integer(@LVDisp));
        ListStr := Temp;
        if (Length(ListStr) = 0) then begin
          ListView_GetItemText(hListView, Index, 0, Temp, Sizeof(Temp) - 1);
          ListStr := Temp;
        end;
        Writeln(TF, 'Item (', Index, ')  = ' + ListStr);
      end;
    Until (Index = -1) or (ItemCount < 0);
  end;
{$ENDIF Logging}
end;

(I have tried a few different subitem indexes)

The text is always blank. Does anybody know what is a possible
solution for this?

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive