Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mutually Exclusive Radio Buttons in Dialogs
#1
Hi,
My question is about hierarchy of controls for mutually exclusive Radio Buttons in Dialogs.

I have a dialog with a bunch of groups of single buttons that can be depressed (a roster of people - with their pics on the button!)

I have added a few "selections" which allows the user to select all in a particular subgroup.
This should naturally cause all the single buttons to become undepressed.

I know that two or more buttons in a dialog with the Specific Style of "0x54013009" i.e. BS_Pushlike, BS_Multiline, and BS_AutoRadioButton) will act in this way.

But I don't know how to make it like a hierarchy i.e.:


  • 2-3 groups of several single choices

    an All button for each group that undepresses only the member of that group but not the singles from the other groups

    an "All All" button that undepresses any of the other buttons (any of the singles or any of the other Alls)

I came across something on the web called RadioButtonList but I don't know if it applies or how to do it in QM.

Any advice would be great!
Thanks,
Stuart
#2
To imagine it better, please post the dialog definition (BEGIN DIALOG...END DIALOG).

There is a function TO_Check somewhere in System. It checks or unchecks multiple checkboxes. You can make a copy and use it in dialog function.

TO_Check2 hDlg "3 4 5" 1 ;;checks checkboxes whose id is 3, 4 and 5
#3
I will also try the TO_Check

The code below is almost there...what I would like however is for the All Group A to uncheck all the Group A individual members (same for Group B) and then the "All Group A and B" button to uncheck (undepress) all the other buttons.
See example below...
Thanks!!
Stuart

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

str controls = "9 5 11 4 6 7 10 12 13"
str o9All o5All o11All c4A c6A c7A c10B c12B c13b


if(!ShowDialog("ButtonHierarchyDialog" &ButtonHierarchyDialog &controls)) ret


;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 391 438 "RadioButtons"
;9 Button 0x54013009 0x0 146 232 78 45 "All Group A and B"
;2 Button 0x54030000 0x4 186 380 78 45 "Cancel"
;1 Button 0x54030001 0x4 104 380 72 45 "OK"
;5 Button 0x54013009 0x0 24 116 78 45 "All Group A"
;11 Button 0x54013009 0x0 208 116 78 45"All Group B"
;3 Static 0x54000000 0x0 50 16 48 12 "Group A"
;4 Button 0x54013003 0x0 50 44 48 14 "A1"
;6 Button 0x54013003 0x0 50 64 48 14 "A2"
;7 Button 0x54013003 0x0 50 86 48 14 "A3"
;8 Static 0x54000000 0x0 226 18 48 12 "Group B"
;10 Button 0x54013003 0x0 224 42 48 14 "B1"
;12 Button 0x54013003 0x0 224 64 48 14 "B3"
;13 Button 0x54013003 0x0 224 86 48 14 "b3"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "*" "" ""


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

sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
#4
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
;g1
if(hDlg) goto messages

str controls = "9 5 11 4 6 7 10 12 13"
str o9All o5All o11All c4A c6A c7A c10B c12B c13b


if(!ShowDialog("ButtonHierarchyDialog" &ButtonHierarchyDialog &controls)) ret


;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 391 438 "RadioButtons"
;9 Button 0x54013009 0x0 146 232 78 45 "All Group A and B"
;2 Button 0x54030000 0x4 186 380 78 45 "Cancel"
;1 Button 0x54030001 0x4 104 380 72 45 "OK"
;5 Button 0x54013009 0x0 24 116 78 45 "All Group A"
;11 Button 0x54013009 0x0 208 116 78 45 "All Group B"
;3 Static 0x54000000 0x0 50 16 48 12 "Group A"
;4 Button 0x54013003 0x0 50 44 48 14 "A1"
;6 Button 0x54013003 0x0 50 64 48 14 "A2"
;7 Button 0x54013003 0x0 50 86 48 14 "A3"
;8 Static 0x54000000 0x0 226 18 48 12 "Group B"
;10 Button 0x54013003 0x0 224 42 48 14 "B1"
;12 Button 0x54013003 0x0 224 64 48 14 "B3"
;13 Button 0x54013003 0x0 224 86 48 14 "b3"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "*" "" ""


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

sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5 ;;All Group A
,TO_Check hDlg "4 6 7" 0
,case 11 ;;All Group B
,TO_Check hDlg "10 12 13" 0
,case 9 ;;All Group A and B
,TO_Check hDlg "4 6 7 10 12 13" 0
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

Replace TO_Check to the name of your copy of TO_Check. Don't use TO_Check because it can be changed or removed in the future.
#5
I changed all the buttons to the regular pushlike style since they act independently (except for what is specified in the TO-Check statements)

I also added the individual buttons to turn off the ALL's otherwise you could get all's and singles depressed if you pressed a single after an ALL.

Works great!!!! Thanks so much!!!!!!

Stuart

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

str controls = "9 5 11 4 6 7 10 12 13"
str o9All o5All o11All c4A c6A c7A c10B c12B c13b


if(!ShowDialog("ButtonHierarchyDialog2" &ButtonHierarchyDialog2 &controls)) ret


;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 391 438 "RadioButtons"
;2 Button 0x54030000 0x4 186 380 78 45 "Cancel"
;1 Button 0x54030001 0x4 104 380 72 45 "OK"
;5 Button 0x54013003 0x0 24 116 78 45 "All Group A"
;9 Button 0x54013003 0x0 146 232 78 45 "All Group A and B"
;11 Button 0x54013003 0x0 208 116 78 45 "All Group B"
;3 Static 0x54000000 0x0 50 16 48 12 "Group A"
;4 Button 0x54013003 0x0 50 44 48 14 "A1"
;6 Button 0x54013003 0x0 50 64 48 14 "A2"
;7 Button 0x54013003 0x0 50 86 48 14 "A3"
;8 Static 0x54000000 0x0 226 18 48 12 "Group B"
;10 Button 0x54013003 0x0 224 42 48 14 "B1"
;12 Button 0x54013003 0x0 224 64 48 14 "B3"
;13 Button 0x54013003 0x0 224 86 48 14 "b3"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "*" "" ""


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

sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4    
,TO_Check hDlg "5 9 11" 0
,case 6
,TO_Check hDlg "5 9 11" 0
,case 7
,TO_Check hDlg "5 9 11" 0
,case 10
,TO_Check hDlg "5 9 11" 0
,case 12
,TO_Check hDlg "5 9 11" 0
,case 13
,TO_Check hDlg "5 9 11" 0
,case 5 ;;All Group A
,TO_Check hDlg "4 6 7 9" 0
,case 11 ;;All Group B
,TO_Check hDlg "10 12 13 9" 0
,case 9 ;;All Group A and B
,TO_Check hDlg "4 6 7 10 12 13 5 11" 0
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
,
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)