Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass items in two combo boxes
#1
How to display the items in the list selection dialog directly to the combo box on the right, as shown in the picture below

The best way is that when I click on an item in the left combo box, the right combo box can directly display the items in it. Smile

This is a comprehensive example, I hope someone can finish it, thanks in advance



Macro Macro3
Code:
Copy      Help
out
str s.getsel
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
_s=atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Add AutoText"
;14 Button 0x54032000 0x0 144 12 48 14 "Edit"
;3 ComboBox 0x54230641 0x0 11 8 120 173 ""
;4 ComboBox 0x54230641 0x0 204 8 120 172 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4"
str cb3 cb4
cb3=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,CB_SelectString(id(3 hDlg) "test")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 14 ;;Edit
,_s.getwintext(id(3 hDlg))
,str ssss items=sub.gotoitemedit(_s)
,items.replacerx("\Q:sub.\E|\;" "     ")
,_i=ListDialog(items "Which item to Edit" "Select item")
,if(_i=0) ret
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOLINE _i 0)
,ssss.getl(items _i-1)
,ssss.trim
,;int ii=findrx(ssss "\d" 0 1)
,int ii=findrx(ssss "Sub." 0 1)
,int cp=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
,cp+ii
,SendMessage(c SCI.SCI_GOTOPOS cp 0)

ret 1


#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim

The following code sometimes does not match the data, Huh for example:

Autotext test
Trigger $t     Help - how to add the trigger to the macro
Code:
Copy      Help
/b/i/c/m
ata :sub.Sub2 ;;china
tes :sub.Sub1 ;;commnet
hel :"hello world" ;;hello world


#sub Sub1 m ;;tes    commnet
_s=
F
;english name
;english name2
PasteAutoInputDialog(_s)


#sub Sub2 m ;;ata    china
_s=
F
;china
PasteAutoInputDialog(_s)
​​​​​​​

 
Code:
Copy      Help
#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim


Attached Files Image(s)
   


Messages In This Thread
Pass items in two combo boxes - by win - 04-20-2019, 01:21 AM
RE: Pass items in two combo boxes - by Kevin - 04-20-2019, 01:49 AM
RE: Pass items in two combo boxes - by win - 04-20-2019, 02:04 AM
RE: Pass items in two combo boxes - by Kevin - 04-20-2019, 02:11 AM
RE: Pass items in two combo boxes - by win - 04-20-2019, 02:22 AM
RE: Pass items in two combo boxes - by win - 04-20-2019, 10:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)