Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unselecting a ComboBox item
#1
Hi,
I am having trouble - how do you unselect a combobox in a smart dialog. It seems that once you select an item, from a list, you can't get that combobox back to an unselected state (i.e. item = -1). I tried adding a dummy item " " i.e. "1[]2[]3[] ". Which works ok but now I have three parallel comboboxes and if the user picks from one, the other two have to go to "unselected"
When I tried something like:


Function Dialog4
Code:
Copy      Help
sel wParam
,case CBN_SELCHANGE<<16|3
,,CB_SelectString(id(4 hDlg) " ")
,,CB_SelectString(id(5 hDlg) " ")
,case CBN_SELCHANGE<<16|4
,,CB_SelectString(id(3 hDlg) " ")
,,CB_SelectString(id(5 hDlg) " ")
,case CBN_SELCHANGE<<16|5
,,CB_SelectString(id(3 hDlg) " ")
,,CB_SelectString(id(4 hDlg) " ")


This caused an unstoppable loop that eventually crashed QM. I tried then instead using CB_SelectItem with an item "-1" but seem to be getting same kind of recursive loop.

This is the simplified code (only two comboboxes):

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


str controls = "3 4"
str cb3 cb4 cb5
cb3 = "1[]2[]3"
cb4="4[]5[]6"
if(!ShowDialog("Dialog4" &Dialog4 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ComboBox 0x54230243 0x0 2 20 96 213 ""
;4 ComboBox 0x54230243 0x0 2 40 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_SELCHANGE<<16|3
,,CB_SelectItem(id(4 hDlg) -1)
,case CBN_SELCHANGE<<16|4
,,CB_SelectItem(id(3 hDlg) -1)
,case IDOK
,case IDCANCEL
ret 1
;

Thanks for any ideas.

Stuart
#2
Something like this?

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

str controls = "4 5 6"
str cb4 cb5 cb6
cb4="1[]2[]3"
cb5="4[]5[]6"
cb6="7[]8[]9"
if(!ShowDialog("Dialog90" &Dialog90 &controls)) ret


;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Stupomer"
;1 Button 0x54030001 0x4 40 112 48 14 "OK"
;2 Button 0x54030000 0x4 104 112 48 14 "Cancel"
;4 ComboBox 0x54230243 0x0 26 40 44 213 ""
;5 ComboBox 0x54230243 0x0 74 40 44 213 ""
;6 ComboBox 0x54230243 0x0 122 40 44 213 ""
;3 Button 0x54020007 0x0 20 6 154 98 "Example Numbers"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)

sel message
,case WM_INITDIALOG
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_SELENDOK<<16|4
,,CB_SelectedItem(id(4 hDlg) combobox_text)
,,sel CB_SelectedItem(lParam)
,,,case 0;; 1
,,,,out combobox_text
,,,case 1;; 2
,,,,out combobox_text
,,,case 2;; 3
,,,,out combobox_text
,case CBN_SELENDOK<<16|5
,,CB_SelectedItem(id(5 hDlg) combobox_text)
,,sel CB_SelectedItem(lParam)
,,,case 0;; 4
,,,,out combobox_text
,,,case 1;; 5
,,,,out combobox_text
,,,case 2;; 6
,,,,out combobox_text
,case CBN_SELENDOK<<16|6
,,CB_SelectedItem(id(6 hDlg) combobox_text)
,,sel CB_SelectedItem(lParam)
,,,case 0;; 7
,,,,out combobox_text
,,,case 1;; 8
,,,,out combobox_text
,,,case 2;; 9
,,,,out combobox_text
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
Taking on Quick Macros one day at a time
#3
Function Function81
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


str controls = "3 4"
str cb3 cb4 cb5
cb3 = "1[]2[]3"
cb4="4[]5[]6"
if(!ShowDialog("" &Function81 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ComboBox 0x54230243 0x0 2 20 96 213 ""
;4 ComboBox 0x54230243 0x0 2 40 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_SELCHANGE<<16|3
,if(CB_SelectedItem(lParam)>=0)
,,CB_SelectItem(id(4 hDlg) -1)
,case CBN_SELCHANGE<<16|4
,if(CB_SelectedItem(lParam)>=0)
,,CB_SelectItem(id(3 hDlg) -1)
,case IDOK
,case IDCANCEL
ret 1
#4
Yes of course ">0" !!!!
Thanks so much - works great.
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)