05-19-2003, 08:59 AM
Function GetItemText
Function GetCount
;/
function# hwndctrl item str&itemtext [ctrltype];;ctrltype: 0 combobox, 1 listbox
;Stores ComboBox or ListBox item text into str variable itemtext.
;item is zero-based item index.
;Returns 1 on success, 0 on failure.
;Does not work with controls that have "owner-draw" style.
;EXAMPLE
;str s sall; int i hwnd=id(1003 "Options")
;for i 0 GetCount(hwnd 0)
,;GetItemText hwnd i &s 0
,;sall.formata("%i. %s[]" i s)
;out sall
if(!&itemtext) end "invalid argument"
itemtext.fix(0)
int msg1 msg2
sel ctrltype
,case 0 msg1=CB_GETLBTEXT; msg2=CB_GETLBTEXTLEN
,case 1 msg1=LB_GETTEXT; msg2=LB_GETTEXTLEN
,case else end "invalid argument"
int tl=SendMessage(hwndctrl msg2 item 0); if(tl<0) ret
tl=SendMessage(hwndctrl msg1 item itemtext.all(tl)); if(tl<0) ret
itemtext.fix(tl)
ret 1
Function GetCount