DcRadioButton Question

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
PedroAlex
Posts: 231
Joined: Tue Feb 09, 2010 3:06 am

DcRadioButton Question

#1 Post 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
Pedro Alexandre

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DcRadioButton Question

#2 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DcRadioButton Question

#3 Post 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
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DcRadioButton Question

#4 Post by Tom »

Besides:

Code: Select all

DCREAD GUI ;
TO OPCAO
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')}
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
PedroAlex
Posts: 231
Joined: Tue Feb 09, 2010 3:06 am

Re: DcRadioButton Question

#5 Post 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
Pedro Alexandre

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DcRadioButton Question

#6 Post 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:

Code: Select all

@ 1,1 DCGROUP oGroup1 ...
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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
PedroAlex
Posts: 231
Joined: Tue Feb 09, 2010 3:06 am

Re: DcRadioButton Question

#7 Post by PedroAlex »

Ok, Tom.

I'll try this.

Many thanks.
Pedro.
Pedro Alexandre

User avatar
PedroAlex
Posts: 231
Joined: Tue Feb 09, 2010 3:06 am

Re: DcRadioButton Question

#8 Post 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
Pedro Alexandre

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DcRadioButton Question

#9 Post by Tom »

:)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DcRadioButton Question

#10 Post 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
Attachments
radio.zip
(84.57 KiB) Downloaded 616 times
The eXpress train is coming - and it has more cars.

Post Reply