Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SelectedItem text
#4
Function GetItemText
Code:
Copy      Help
;/
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
Code:
Copy      Help
;/
function# hwndctrl [ctrltype]

int msg
sel(ctrltype) case 0 msg=CB_GETCOUNT; case 1 msg=LB_GETCOUNT; case else end "invalid argument"

ret SendMessage(hwndctrl msg 0 0)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)