Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manipulating combo box from dialog
#1
Hi, I have two combo boxes on a dialog(A, B, C) and (1, 2, 3) What is displayed in combo box 2 needs to be dependent on what is chosen in combo box 1 - this all needs to be done in the dialog itself before the macro is run.

So if B in combo box one is chosen then combo box two should have its contents changed from 1,2,3 to 4,5,6

I have tried to piece this together using the forum posts, but I can't get it to work.

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

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 ComboBox 0x54230243 0x0 12 18 96 213 ""
;4 ComboBox 0x54230243 0x0 14 40 96 213 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""
str controls = "3 4"
str cb3 cb4
cb3="&A[]B[]C"
cb4="&1[]2[]3"
if(!ShowDialog("combo" 0 &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_APP

ret
;messages2
sel wParam
,case CBN_SELENDOK<<16|3
,int selected = CB_SelectedItem(id(3 hDlg))
,int othercombo = (id(4hDlg))
,if selected=1
,,SendMessage othercombo CB_RESETCONTENT 0 0
,,CB_Add othercombo "4" 0
,,CB_Add othercombo "5" 1
,,CB_Add othercombo "6" 2
,case IDCANCEL
ret 1

Any help would be greatly appreciated.

Matt
#2
Function dlg_combo
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4"
str cb3 cb4
cb3="&A[]B[]C"
cb4="&1[]2[]3"

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 ComboBox 0x54230243 0x0 12 18 96 213 ""
;4 ComboBox 0x54230243 0x0 14 40 96 213 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030501 "*" "" "" ""

if(!ShowDialog("dlg_combo" &dlg_combo &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_SELENDOK<<16|3
,_i=CB_SelectedItem(lParam); if(_i<0) ret
,sel _i
,,case 0 _s="1[]2[]3";; A
,,case 1 _s="4[]5[]6";; B
,,case 2 _s="7[]8[]9";; C
,TO_CBFill id(4 hDlg) _s
,;CB_SelectItem id(4 hDlg) 0
,case IDOK
,case IDCANCEL
ret 1
#3
Brilliant! Thank you very much Smile

Matt


Forum Jump:


Users browsing this thread: 1 Guest(s)