Radio button set with none pre-selected

Started by stevengraff, July 30, 2014, 09:43:33 AM

Previous topic - Next topic

stevengraff

Is it possible to have a dialog that comes up with none of its radio buttons pre-selected as default? I don't want to play favorites.

Deana

Just curious, why use radiobuttons? Sounds like a job for checkboxes.
Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

User will ultimately select one (and only one) item.

See dialog here: http://screencast.com/t/xLp70HoEGjUV

Deana

I suppose you could create a dialog callback procedure that merely unsets the default Radiobutton in the initialization procedure.

For Example:
Code (winbatch) Select
#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   MSG_INIT = 0
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   switch MyDialog_Message                                  ; Switch based on Dialog Message type
      case MSG_INIT                                         ; Standard Initialization message
          DialogControlSet( MyDialog_Handle, 'RadioButton_1', 2, 0 )
         return(RET_DO_DEFAULT)
   endswitch                                                ; MyDialog_Message
   return(RET_DO_DEFAULT)
#EndFunction                                                ; End of Dialog Callback MyDialogCallbackProc


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog`
MyDialogX=048
MyDialogY=065
MyDialogWidth=304
MyDialogHeight=193
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`025,019,050,012,RADIOBUTTON,"RadioButton_1",drive1,"radio1",1,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`025,039,050,012,RADIOBUTTON,"RadioButton_2",drive1,"radio2",2,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`025,057,050,012,RADIOBUTTON,"RadioButton_3",drive1,"radio3",3,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`089,129,036,012,PUSHBUTTON,"PushButton_1",DEFAULT,"Ok",1,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Deana F.
Technical Support
Wilson WindowWare Inc.

td

Each radio button of a group has a value associated with it and each radio button of a group has the same variable associated with it.  The variable association is what makes the several radio buttons a group.   

If you set that radio button variable to a value other than zero that is not associated with any of the group's buttons before you call the Dialog function, no button will be 'dotted' when the dialog containing the radio group starts.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stevengraff

Quote from: Deana on July 30, 2014, 11:25:07 AM
I suppose you could create a dialog callback procedure that merely unsets the default Radiobutton in the initialization procedure.

For Example:
Code (winbatch) Select
#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   MSG_INIT = 0
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   switch MyDialog_Message                                  ; Switch based on Dialog Message type
      case MSG_INIT                                         ; Standard Initialization message
          DialogControlSet( MyDialog_Handle, 'RadioButton_1', 2, 0 )
         return(RET_DO_DEFAULT)
   endswitch                                                ; MyDialog_Message
   return(RET_DO_DEFAULT)
#EndFunction                                                ; End of Dialog Callback MyDialogCallbackProc


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog`
MyDialogX=048
MyDialogY=065
MyDialogWidth=304
MyDialogHeight=193
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`025,019,050,012,RADIOBUTTON,"RadioButton_1",drive1,"radio1",1,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`025,039,050,012,RADIOBUTTON,"RadioButton_2",drive1,"radio2",2,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`025,057,050,012,RADIOBUTTON,"RadioButton_3",drive1,"radio3",3,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`089,129,036,012,PUSHBUTTON,"PushButton_1",DEFAULT,"Ok",1,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")


Thanks; somehow I hadn't expected it to be so straightforward.

stevengraff

Quote from: td on July 30, 2014, 11:48:49 AM
Each radio button of a group has a value associated with it and each radio button of a group has the same variable associated with it.  The variable association is what makes the several radio buttons a group.   

If you set that radio button variable to a value other than zero that is not associated with any of the group's buttons before you call the Dialog function, no button will be 'dotted' when the dialog containing the radio group starts.

Clever; thanks.