Page 1 of 1
DcRadioButton Question
Posted: Mon Jun 22, 2015 8:52 am
by PedroAlex
Hello.
Anyone can test this code and comment if it works well?
Code: Select all
Procedure DCRADIO_Teste()
LOCAL GetList := {}, GetOptions,;
cOption := 'A',;
cTeste := 1
@ 1,5 DCRADIOBUTTON cOption PROMPT 'Option A' VALUE 'A'
@ 2,5 DCRADIOBUTTON cOption PROMPT 'Option B' VALUE 'B'
@ 3,5 DCRADIOBUTTON cOption PROMPT 'Option C' VALUE 'C'
@ 4,5 DCRADIOBUTTON cOption PROMPT 'Option D' VALUE 'D'
@ 1,20 DCRADIOBUTTON cTeste PROMPT 'Value 1' VALUE 1
@ 2,20 DCRADIOBUTTON cTeste PROMPT 'Value 2' VALUE 2
@ 3,20 DCRADIOBUTTON cTeste PROMPT 'Value 3' VALUE 3
@ 4,20 DCRADIOBUTTON cTeste PROMPT 'Value 4' VALUE 4
DCGETOPTIONS SAYFONT '10.Arial Bold'
DCREAD GUI ;
TO OPCAO ;
TITLE 'Radio Button Demo' ;
FIT ;
OPTIONS GetOptions ;
MODAL ;
ADDBUTTONS ;
SETAPPWINDOW
Return
Why select 'option' clean 'value'
Many thanks
Pedro
Re: DcRadioButton Question
Posted: Mon Jun 22, 2015 9:20 am
by Tom
Hi, Pedro.
DCRADIObuttons need to have a parent in order to be grouped and work well. You need to place the buttons for "cOption" on one parent (a DCGROUP or a DCSTATIC/Text) and the buttons for "cTeste" on another parent.
Re: DcRadioButton Question
Posted: Mon Jun 22, 2015 9:37 am
by Tom
Code: Select all
Procedure DCRADIO_Teste()
LOCAL GetList := {}, GetOptions,;
cOption := 'A',;
cTeste := 1, oGroup1, oGroup2
@ 1,1 DCGROUP oGroup1 CAPTION 'Option' SIZE 50,5.5
DCSETPARENT TO oGroup1
@ 1,5 DCRADIOBUTTON cOption PROMPT 'Option A' VALUE 'A'
@ 2,5 DCRADIOBUTTON cOption PROMPT 'Option B' VALUE 'B'
@ 3,5 DCRADIOBUTTON cOption PROMPT 'Option C' VALUE 'C'
@ 4,5 DCRADIOBUTTON cOption PROMPT 'Option D' VALUE 'D'
DCSETPARENT TO
@ 7,1 DCGROUP oGroup2 CAPTION 'Test' SIZE 50,5.5
DCSETPARENT TO oGroup2
@ 1,5 DCRADIOBUTTON cTeste PROMPT 'Value 1' VALUE 1
@ 2,5 DCRADIOBUTTON cTeste PROMPT 'Value 2' VALUE 2
@ 3,5 DCRADIOBUTTON cTeste PROMPT 'Value 3' VALUE 3
@ 4,5 DCRADIOBUTTON cTeste PROMPT 'Value 4' VALUE 4
DCSETPARENT TO
DCGETOPTIONS SAYFONT '10.Arial Bold'
DCREAD GUI ;
TO OPCAO ;
TITLE 'Radio Button Demo' ;
FIT ;
OPTIONS GetOptions ;
MODAL ;
ADDBUTTONS ;
SETAPPWINDOW
Return
Re: DcRadioButton Question
Posted: Mon Jun 22, 2015 10:26 am
by Tom
Besides:
The "TO"-clause of DCREAD populates a boolean with .T. or .F., depending on the user interaction (clicking "Abort" or the cross symbol leads to .F., clicking "OK" to .T.).
Code: Select all
FUNCTION MyDialog()
LOCAL GetList := {}, GetOptions := {}, lOk := .F.
DCREAD ... TO lOk
"lOk" will contain .T. if the user clicked "OK" and .F. in all other cases.
Since the first character of the variable ("OPCAO") is an "O", I assume you expect it to contain the dialog object itself. This is not true. If you want to keep and access the dialog object, do this:
Code: Select all
FUNCTION MyDialog()
LOCAL GetList := {}, GetOptions := {}, lOk := .F., oDialog
DCREAD PARENT @oDialog ... TO lOk
You will be able to access "oDialog" inside the dialog if you want:
Code: Select all
@ 1,1 DCPUSHBUTTON CAPTION 'Test' SIZE 10,1 ACTION {||oDialog:SetTitle('Another title')}
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 2:13 am
by PedroAlex
Tom.
Many Thanks for help.
the "DcRadio" to operate in this way does not fit what I need to do.
I need a window with many dcradio on different fields and variables and all in the same group.
Having this limitation...
I have to do this based on dcget or dcpushbuttons.
best regards.
Pedro
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 2:43 am
by Tom
Hi, Pedro.
You don't need to use DCGROUPs for grouping the radiobuttons. You may use invisible text statics as the parent(s), so the user won't see the grouping. Just replace:
with
Code: Select all
@ 1,1 DCSAY '' SIZE 50,5.5 COLOR XBPSYSCLR_TRANSPARENT,XBPSYSCLR_TRANSPARENT OBJECT oGroup1
This will give the result you want and work properly. The only thing you need to know: DCRADIOs populating the same variable need a concrete parent in order to work well.
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 3:50 am
by PedroAlex
Ok, Tom.
I'll try this.
Many thanks.
Pedro.
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 4:49 am
by PedroAlex
Just for share...
This works like I need.
independente DcradioButtons in the same Group.
Code: Select all
//-------------------------------------------------
Procedure DCRADIO_Teste()
LOCAL GetList := {}, GetOptions,;
cOption := 'A',;
cTeste := 1
@ 01,05 DCGROUP oGroup1 SIZE 30,6 CAPTION 'Group Alfa' FONT '10.Arial Bold'
@ 01,00 DCSAY '' SIZE 15,4 COLOR XBPSYSCLR_TRANSPARENT,XBPSYSCLR_TRANSPARENT OBJECT oGc1 Parent oGroup1
@ 0,1 DCRADIOBUTTON cOption PROMPT 'Option A' VALUE 'A' Parent oGc1
@ 1,1 DCRADIOBUTTON cOption PROMPT 'Option B' VALUE 'B' Parent oGc1
@ 2,1 DCRADIOBUTTON cOption PROMPT 'Option C' VALUE 'C' Parent oGc1
@ 3,1 DCRADIOBUTTON cOption PROMPT 'Option D' VALUE 'D' Parent oGc1
@ 01,15 DCSAY '' SIZE 15,4 COLOR XBPSYSCLR_TRANSPARENT,XBPSYSCLR_TRANSPARENT OBJECT oGc2 Parent oGroup1
@ 0,1 DCRADIOBUTTON cTeste PROMPT 'Value 1' VALUE 1 Parent oGc2
@ 1,1 DCRADIOBUTTON cTeste PROMPT 'Value 2' VALUE 2 Parent oGc2
@ 2,1 DCRADIOBUTTON cTeste PROMPT 'Value 3' VALUE 3 Parent oGc2
@ 3,1 DCRADIOBUTTON cTeste PROMPT 'Value 4' VALUE 4 Parent oGc2
DCGETOPTIONS SAYFONT '10.Arial Bold'
DCREAD GUI ;
TITLE 'Radio Button Demo' ;
FIT ;
OPTIONS GetOptions ;
MODAL ;
ADDBUTTONS ;
SETAPPWINDOW
Return
Tom
Many thanks
Pedro
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 5:05 am
by Tom
Re: DcRadioButton Question
Posted: Tue Jun 23, 2015 7:14 am
by rdonnay
Pedro and Tom -
I have been following this thread and I decided it may be useful to add a new feature to DCRADIOBUTTON.
I added a new clause: RADIOGROUP.
This accepts a variable that must be initialized as an empty array.
This new feature will eliminate the need to have unique parents for each radio group when desired.
Look at this test code:
Code: Select all
#INCLUDE "dcdialog.ch"
FUNCTION main
LOCAL GetList[0], aGroup1[0], aGroup2[0], aGroup3[0], ;
cValue := 'A', nValue := 1, cValue2 := 'Z'
@ 0,0 DCRADIO nValue VALUE 1 PROMPT '1' RADIOGROUP aGroup1
@ 1,0 DCRADIO nValue VALUE 2 PROMPT '2' RADIOGROUP aGroup1
@ 2,0 DCRADIO nValue VALUE 3 PROMPT '3' RADIOGROUP aGroup1
@ 3,0 DCRADIO nValue VALUE 4 PROMPT '4' RADIOGROUP aGroup1
@ 5,0 DCRADIO cValue VALUE 'A' PROMPT 'A' RADIOGROUP aGroup2
@ 6,0 DCRADIO cValue VALUE 'B' PROMPT 'B' RADIOGROUP aGroup2 ACTION {||(wtf 'here')}
@ 7,0 DCRADIO cValue VALUE 'C' PROMPT 'C' RADIOGROUP aGroup2
@ 8,0 DCRADIO cValue VALUE 'D' PROMPT 'D' RADIOGROUP aGroup2
@10,0 DCRADIO cValue2 VALUE 'W' PROMPT 'W' RADIOGROUP aGroup3
@11,0 DCRADIO cValue2 VALUE 'X' PROMPT 'X' RADIOGROUP aGroup3 ACTION {||(wtf 'here')}
@12,0 DCRADIO cValue2 VALUE 'Y' PROMPT 'Y' RADIOGROUP aGroup3
@13,0 DCRADIO cValue2 VALUE 'Z' PROMPT 'Z' RADIOGROUP aGroup3
DCREAD GUI FIT ADDBUTTONS TITLE 'Radio Group Test'
RETURN nil
PROC appsys ; RETURN
You will need an updated DCDIALOG.CH and _DCCLASS.PRG (attached)
Copy DCDIALOG.CH to \exp20\include
Copy _DCCLASS.PRG to \exp20\source\dclips and run BUILD19_SL1.BAT or BUILD20.BAT to rebuild DCLIPX.DLL