Page 1 of 1

USER32.DLL and LISTBOX

Posted: Mon Dec 20, 2004 9:31 pm
by PATLOU
Can anyone give me the synthax of calling user32.dll which allows to retireve the text in a listbox controls
Thanks

Posted: Mon Dec 20, 2004 10:18 pm
by RJP Computing
Doesn't 'GetGadgetText' work for you. Also you can get a specific item out of the ListView by using 'GetGadgetItemText'.

Posted: Tue Dec 21, 2004 8:01 am
by PATLOU
Yes I know , but it is a specific things. I want to read the contents of an listbox in another programm which is not created by purebasic

Posted: Tue Dec 21, 2004 11:41 am
by GreenGiant
Your main problem might be finding out the handle of the external listbox, but here's some code that should read its text once you have. In my example its reading one I've created, but it should still do the job if you feed in the handle of an external control.

Code: Select all

OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"Test")
CreateGadgetList(WindowID())
  ListViewGadget(0,10,10,380,380)
  AddGadgetItem(0,-1,"This is a line of text")
  AddGadgetItem(0,-1,"This is another")
  AddGadgetItem(0,-1,"And so on...")

    listhandle=GadgetID(0) ;This needs to be the handle of your external listbox

    listcount=SendMessage_(listhandle,#LB_GETCOUNT,0,0)
    For temp=0 To listcount-1
      length=SendMessage_(listhandle,#LB_GETTEXTLEN,temp,0)
      tempstring$=Space(length)
      SendMessage_(listhandle,#LB_GETTEXT,temp,@tempstring$)
      string$=string$+" "+tempstring$
    Next

Debug string$

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow

Posted: Tue Dec 21, 2004 5:56 pm
by PATLOU
It seems that's my Listbox is a non standard Listbox which doesn't respond to LB_GETTEXT.

Posted: Tue Dec 21, 2004 10:42 pm
by freak
It does probably not work, because when you call SendMessage_() with
your own memory buffer for the returned text, that foreign app isn't able
to write to that memory location.

It is possible to do that, but it requires a little hacking around.