USER32.DLL and LISTBOX

Just starting out? Need help? Post your questions and find answers here.
PATLOU
User
User
Posts: 12
Joined: Mon Oct 18, 2004 6:24 am

USER32.DLL and LISTBOX

Post by PATLOU »

Can anyone give me the synthax of calling user32.dll which allows to retireve the text in a listbox controls
Thanks
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

Post by RJP Computing »

Doesn't 'GetGadgetText' work for you. Also you can get a specific item out of the ListView by using 'GetGadgetItemText'.
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
PATLOU
User
User
Posts: 12
Joined: Mon Oct 18, 2004 6:24 am

Post 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
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post 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
PATLOU
User
User
Posts: 12
Joined: Mon Oct 18, 2004 6:24 am

Post by PATLOU »

It seems that's my Listbox is a non standard Listbox which doesn't respond to LB_GETTEXT.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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.
quidquid Latine dictum sit altum videtur
Post Reply