Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog with Muti Text Boxes on change
#1
Question 
I am trying to show a dialog with many text boxes

image

I want the last text box to join the text in all the text boxes using a specific pattern
when I am entering the text in any text box

like this:
tbxRes=F"{textbox01}, {textbox02}, {textbox03}, {textbox04}"
#2
2 examples.
I didn't know if you actually meant the contents of "textbox02" or " textbox02" literal.
My code is not as beautiful or clean as others can give here (read: my examples can be done a lot cleaner/better)
Bbut maybe it can help.

In stead of "textbox02" I used "field_1" , "field_2",....
And I assumed you wanted to have the bottom field updated as soon text is changed/entered in one of the above inputfields.

EXAMPLE 1: contents of "textbox02"

Function demo_input_dlg1
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 202 100 "Dialog" "4"
;3 Static 0x54000000 0x0 10 15 48 12 "field 1"
;4 Edit 0x54030080 0x200 60 15 96 12 ""
;5 Static 0x54000000 0x0 10 35 48 12 "field 2"
;6 Edit 0x54030080 0x200 60 35 96 12 ""
;7 Static 0x54000000 0x4 10 55 48 12 "field 3"
;8 Edit 0x54030080 0x204 60 55 96 13 ""
;9 Edit 0x54030080 0x200 10 75 146 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 6 8 9"
str e4 e6 e8 e9
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,str field_1 field_2 field_3
,,str f1 f2 f3 fin
,,int- b
,,str fill_string
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam

,case EN_CHANGE<<16|4
,,if(b=1)b=0;ret        
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,fin=F"{field_1},{field_2},{field_3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0

,case EN_CHANGE<<16|6
,,if(b=1)b=0;ret
,,b=1
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,fin=F"{field_1},{field_2},{field_3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0
,,
,case EN_CHANGE<<16|8
,,if(b=1)b=0;ret
,,b=1
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,fin=F"{field_1},{field_2},{field_3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0
ret 1

EXAMPLE 2: literal "textbox02"

Function demo_input_dlg2
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 202 100 "Dialog" "4"
;3 Static 0x54000000 0x0 10 15 48 12 "field 1"
;4 Edit 0x54030080 0x200 60 15 96 12 ""
;5 Static 0x54000000 0x0 10 35 48 12 "field 2"
;6 Edit 0x54030080 0x200 60 35 96 12 ""
;7 Static 0x54000000 0x4 10 55 48 12 "field 3"
;8 Edit 0x54030080 0x204 60 55 96 13 ""
;9 Edit 0x54030080 0x200 10 75 146 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 6 8 9"
str e4 e6 e8 e9
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,str field_1 field_2 field_3
,,str f1 f2 f3 fin
,,int- b
,,str fill_string
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam

,case EN_CHANGE<<16|4
,,if(b=1)b=0;ret
,,b=1
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,if(!empty(field_1))f1="{field_1}"
,,if(!empty(field_2))f2="{field_2}"
,,if(!empty(field_3))f3="{field_3}"
,,fin=F"{f1},{f2},{f3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,

,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0

,case EN_CHANGE<<16|6
,,if(b=1)b=0;ret
,,b=1
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,if(!empty(field_1))f1="{field_1}"
,,if(!empty(field_2))f2="{field_2}"
,,if(!empty(field_3))f3="{field_3}"
,,fin=F"{f1},{f2},{f3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,

,,
,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0
,,
,case EN_CHANGE<<16|8
,,if(b=1)b=0;ret
,,b=1
,,field_1.getwintext(id(4 hDlg))
,,field_2.getwintext(id(6 hDlg))
,,field_3.getwintext(id(8 hDlg))
,,if(!empty(field_1))f1="{field_1}"
,,if(!empty(field_2))f2="{field_2}"
,,if(!empty(field_3))f3="{field_3}"
,,fin=F"{f1},{f2},{f3}"
,,fin.trim(",");fin.findreplace(",," ",")
,,_s=F"tbxRes=F''{fin}''"
,,b=1
,,_s.setwintext(id(9 hDlg))
,,b=0
ret 1
#3
this is much simpler 
 
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 202 100 "Dialog" "4"
;3 Static 0x54000000 0x0 10 15 48 12 "field 1"
;4 Edit 0x54030080 0x200 60 15 96 12 ""
;5 Static 0x54000000 0x0 10 35 48 12 "field 2"
;6 Edit 0x54030080 0x200 60 35 96 12 ""
;7 Static 0x54000000 0x4 10 55 48 12 "field 3"
;8 Edit 0x54030080 0x204 60 55 96 13 ""
;9 Edit 0x54030080 0x200 10 75 146 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 6 8 9"
str e4 e6 e8 e9
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v;; must have v attribute
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [EN_CHANGE<<16|4,EN_CHANGE<<16|6,EN_CHANGE<<16|8]
,DT_GetControls(hDlg)
,_s=F"{e4},{e6},{e8}"
,;; e4,e6,e8 are  variables created by dialog editor as shown in this line "str e4 e6 e8 e9" above and need to be changed to match your dialog variables
,DT_SetControl(hDlg 9 _s)

ret 1
#4
thank you very much r0n and Kevin 
It's good opportunity to study your code and learn from it.
It works

Mr. Kevin
I need your help to go one more step further.

I am going to use some combo boxes as replacement for some text boxes and as I am changing selection from combo boxes or text boxes the result text box will join all the text.

Thank you 
Firas
#5
something like this
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 166 144 "Dialog" "4"
;3 Static 0x54000000 0x0 10 15 48 12 "field 1"
;4 Edit 0x54030080 0x200 60 15 92 12 ""
;5 Static 0x54000000 0x0 10 35 48 12 "field 2"
;6 Edit 0x54030080 0x200 60 35 92 12 ""
;7 Static 0x54000000 0x4 10 55 48 12 "field 3"
;8 Edit 0x54030080 0x204 60 55 92 12 ""
;9 Edit 0x54030080 0x200 9 119 144 12 ""
;10 ComboBox 0x54230243 0x0 60 75 92 213 ""
;11 Static 0x54000000 0x0 10 75 48 12 "combo1"
;12 Static 0x54000000 0x0 10 95 48 12 "combo2"
;13 ComboBox 0x54230243 0x0 60 95 92 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 6 8 9 10 13"
str e4 e6 e8 e9 cb10 cb13
cb10=
;one
;two
;three

cb13=
;four
;five
;six

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc v;; must have v attribute
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [EN_CHANGE<<16|4,EN_CHANGE<<16|6,EN_CHANGE<<16|8,CBN_SELENDOK<<16|10,CBN_SELENDOK<<16|13]
,DT_GetControls(hDlg)
,str cbt1=iif((cb10.replacerx("\d* " "")=0) "" cb10)
,str cbt2=iif((cb13.replacerx("\d* " "")=0) "" cb13)
,_s=F"{e4},{e6},{e8},{cbt1},{cbt2}"
,;; e4,e6,e8 are  variables created by dialog editor as shown in this line "str e4 e6 e8 e9" above and need to be changed to match your dialog variables
,DT_SetControl(hDlg 9 _s)

ret 1
#6
Thank you Mr. Kevin its' working
It's great how your code is simple clean and effective 
Bunch of Thanks Sir


Forum Jump:


Users browsing this thread: 2 Guest(s)