Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SelectedItem text
#2
Replace SelectedItem text to text below. To save, export System folder.
Code:
Copy      Help
;/
function# hwndctrl [ctrltype] [str&itemtext];;ctrltype: 0 combobox, 1 listbox

;Returns zero based index of selected item of combo
;box or list box. If no selection, returns -1.
;Can also get selected item text.

;EXAMPLES
;1. Get item index:
;out SelectedItem(id(1136 "Open"))

;2. Get item text:
;str s
;SelectedItem(id(1136 "Open") 0 &s)
;out s


if(hwndctrl=0) ret -1
int i msg1 msg2 msg3
sel ctrltype
,case 0 msg1=CB_GETCURSEL; msg2=CB_GETLBTEXT; msg3=CB_GETLBTEXTLEN
,case 1 msg1=LB_GETCURSEL; msg2=LB_GETTEXT; msg3=LB_GETTEXTLEN
,case else end ""

i=SendMessage(hwndctrl msg1 0 0)
if(&itemtext and i>=0)
,itemtext.fix(SendMessage(hwndctrl msg2 i itemtext.all(SendMessage(hwndctrl msg3 i 0))))
ret i


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)