Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Choose a group from a user input
#2
this may be more than you wanted but try this

dialog with 2 list boxes
list 1 is populated at run time
list 2 is populated on selection of list 1 item
on double left click of list2 item closes dialog and outputs selected list 2 item
Function Dialog2LBExample
Code:
Copy      Help
str li=
;Start
;
;##2
;folder#1
;folder#2
;EndOfList
;
;##3
;folder#3
;folder#4
;EndOfList
;
;##4
;folder#5
;EndOfList

str list1 lb1text lb2text s
int lb1h lb2h
ARRAY(str) a b
findrx(li "\#\#\d*" 0 4 a)
for _i 0 a.len
,list1.addline(a[0 _i].trim 1)

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 ListBox 0x54230101 0x200 0 16 96 96 ""
;4 ListBox 0x54230101 0x200 120 16 96 96 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

str controls = "3 4"
str lb3 lb4
lb3=list1
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
;lb4.replacerx("\d+ " "")
;out lb4
out lb2text

#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,lb1h=id(3 hDlg)
,lb2h=id(4 hDlg)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
,_i=LB_SelectedItem(lParam lb1text)
,if(_i=-1) ret
,str pattern=F"(?s){lb1text}(.+?)EndOfList"
,SendMessage(lb2h LB_RESETCONTENT 0 0)
,findrx(li pattern 0 4 b 1)
,_s=b; _s.trim
,foreach s _s
,,LB_Add(lb2h s)
,case LBN_DBLCLK<<16|4
,_i=LB_SelectedItem(lParam lb2text)
,if(_i=-1) ret
,DT_Ok(hDlg)
ret 1


Messages In This Thread
Choose a group from a user input - by ScottF - 11-17-2022, 01:17 PM
RE: Choose a group from a user input - by Kevin - 11-17-2022, 07:17 PM
RE: Choose a group from a user input - by ScottF - 11-17-2022, 09:44 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)