Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple listboxes with different actions.
#1
Hello!

How can i create a dialog with multiple listboxes and use these as input?

For example:

Listbox 1: a/b/c
Listbox 2: 1/2/3 or 5/6/7
Listbox 3: one/two/three

If in listbox 1 a is selected, the 1/2/3 option in listbox 2 should apear, if b is selected, 5,6,7 should apear
When in listbox 3 two is selected is should message 'a happy welcome' when three is selected the message should be 'poor you'

Can somebody give me an example for this?
#2
Function Dialog134
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4"
str lb3 lb4
lb3="a[]b[]c"
if(!ShowDialog("Dialog134" &Dialog134 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 135 "Dialog"
;3 ListBox 0x54230101 0x200 0 0 96 48 ""
;4 ListBox 0x54230109 0x200 106 0 96 48 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|3
,int hlb2=id(4 hDlg)
,SendMessage hlb2 LB_RESETCONTENT 0 0
,_i=LB_SelectedItem(lParam)
,str s ss
,sel _i
,,case 0 s="1[]2[]3"
,,case 1 s="5[]6[]7"
,foreach ss s
,,LB_Add hlb2 ss
,
,case IDOK
,case IDCANCEL
ret 1
#3
Gintaras, thank you for this!

Is the last thing i asked also possible, when in another listbox, the third one, is selected something, the action depends on what is selected?

So listbox 1: a so a selection in listbox 2 is 3 and when finaly in listbox 3 'two' is selected a message apears?

Thanks in advance for your time!
#4
Can't this be done?
I really appreciate any help with this!

Sonic
#5
Code for listbox 3 would be similar as for listbox 1, just simpler. Or i don't understand question.
#6
Hello Gintaras,

What I mean is that the action depends on the selection in the different listboxes.

When in the second listbox a selection was made, the selection in the third listbox gives another action than another selection in the second listbox.

By example

Listbox 1 the selection is 'a'
The second lisbox gives a possible selection of 1/2/3
Listbox 1 the selection is 'b'
The second lisbox gives possible selection of 4/5/6

When in second listbox 2 is selected, the third listbox gives possible selection of one/two
when 'one' is selected a message appears.

But when in second listbox the selection was 5 (which depends on selection in first listbox) another message appears.

I hope you can help me with this, and that this is a better explenation for what i need.

Greetings

Sonic
#7
The example shows how to use functions and events for tasks like this.
Add another event LBN_SELCHANGE to execute code when listbox 3 selected. You can add it in Dialog Editor.
Use function LB_SelectedItem to get index of selected item in any listbox. Use id(your_listbox_id hDlg) instead of lParam.
Then use sel _i to execute different code depending on what is selected.
#8
Thanks for your answer!

But when i try this, the action doesn't differ from the first selection. It doesn't seem to matter what selection in the first or second listbox was made... the case-index 0/1/2 cannot 'see' what the previous selection was...

I'm sorry when i look stupid, but when you can help me with this (and you do) it would be great!

Sonic
#9
Function Dialog134
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5"
str lb3 lb4 lb5
lb3="a[]b[]c"
lb5="one[]two[]three"
if(!ShowDialog("Dialog134" &Dialog134 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 135 "Dialog"
;3 ListBox 0x54230101 0x200 0 0 96 48 ""
;4 ListBox 0x54230101 0x200 106 0 96 48 ""
;5 ListBox 0x54230101 0x200 56 56 96 48 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|3 ;;listbox 1
,int hlb2=id(4 hDlg)
,SendMessage hlb2 LB_RESETCONTENT 0 0
,_i=LB_SelectedItem(lParam)
,str s ss
,sel _i
,,case 0 s="1[]2[]3"
,,case 1 s="5[]6[]7"
,foreach ss s
,,LB_Add hlb2 ss
,
,case LBN_SELCHANGE<<16|4 ;;listbox 2
,_i=LB_SelectedItem(lParam)
,out _i
,
,case LBN_SELCHANGE<<16|5 ;;listbox 3
,int selectedInLB2 selectedInLB3
,selectedInLB2=LB_SelectedItem(id(4 hDlg))
,selectedInLB3=LB_SelectedItem(id(5 hDlg))
,mes F"selectedInLB2={selectedInLB2}[]selectedInLB3={selectedInLB3}"
,
,case IDOK
,case IDCANCEL
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)