08-08-2007, 09:50 AM
Example
Function Dialog35 (example)
Function LB_GetSelectedItems (universal)
ARRAY(str)- t_af
str controls = "3"
str lb3
if(!ShowDialog("Dialog35" &Dialog35 &controls)) ret
out t_afFunction Dialog35 (example)
;\Dialog_Editor
function# hDlg message wParam lParam
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ListBox 0x54230109 0x200 4 4 130 109 ""
;4 Button 0x54032000 0x0 4 118 48 14 "Desktop"
;END DIALOG
;DIALOG EDITOR: "" 0x2020100 "" ""
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4 ;;Desktop
,int hlb=id(3 hDlg)
,SendMessage hlb LB_RESETCONTENT 0 0
,Dir d
,foreach(d "$Desktop$\*" FE_Dir)
,,SendMessage hlb LB_ADDSTRING 0 d.FileName
,,
,case IDOK
,ARRAY(str)- t_af
,LB_GetSelectedItems id(3 hDlg) t_af
,case IDCANCEL
ret 1Function LB_GetSelectedItems (universal)
;/
function hlb ARRAY(str)&a
;Gets text of selected items in a multiple-selection listbox.
int i n=SendMessage(hlb LB_GETSELCOUNT 0 0)
if(n=-1) ;;single-sel control
,a.redim(1)
,if(LB_SelectedItem(hlb a[0])<0) a.redim
else
,a.redim(n)
,if(n)
,,ARRAY(int) selitems.create(n)
,,SendMessage(hlb LB_GETSELITEMS n &selitems[0])
,,for(i 0 n) LB_GetItemText hlb selitems[i] a[i]