How to disable an item of a radio control

How to disable an item of a radio control

Postby hua » Tue Jun 09, 2015 4:04 am

Below is the code that I use to test. I couldn't get it to work

Code: Select all  Expand view

#include "FiveWin.ch"

function Main()

   local oDlg, oRadMenu
   local nOption := 1

   DEFINE DIALOG oDlg RESOURCE "Radios"

   REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg ;
      WHEN MyFunc()

   REDEFINE BUTTON ID 100 OF oDlg ACTION oRadMenu:aItems[2]:disable()

   REDEFINE BUTTON ID 102 OF oDlg ACTION oRadMenu:aItems[2]:enable()

   ACTIVATE DIALOG oDlg CENTERED

return nil

function MyFunc()
return .t.
 


Code: Select all  Expand view

radios DIALOG 46, 44, 127, 86
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Testing Radio Buttons"
FONT 10, "MS Sans Serif"
{
 GROUPBOX "&Some Radios", 107, 5, 6, 70, 75, BS_GROUPBOX | WS_CHILD | WS_VISIBLE
 CONTROL "&One", 110, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 10, 16, 28, 12
 CONTROL "&Two", 120, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 10, 28, 28, 12
 CONTROL "T&hree", 130, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 10, 40, 28, 12
 CONTROL "&Four", 140, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 10, 52, 28, 12
 CONTROL "F&ive", 150, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 10, 63, 28, 12
 PUSHBUTTON "&Disable 2", 100, 81, 10, 41, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP
 PUSHBUTTON "&Enable 2", 102, 81, 24, 41, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP
 PUSHBUTTON "&Cancel", 2, 81, 38, 41, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP
}
 


TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1050
Joined: Fri Oct 28, 2005 2:27 am

Re: How to disable an item of a radio control

Postby joseluisysturiz » Tue Jun 09, 2015 5:29 am

Intenta validar en el ON CHANGE el valor capturado en la VAR del radio, si es dicho valor...has que sea otro y asi lo saltas, basado en la condicion que quieras, es una idea, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: How to disable an item of a radio control

Postby ukoenig » Tue Jun 09, 2015 7:00 am

a working sample .

REDEFINE RADIO oRadio1 VAR nRadio1 ID 170 , 171, 172 OF oFld:aDialogs[ 2 ] UPDATE
AEval( oRadio1:aItems, { | oRad | oRad:lTransparent := .T., ;

oRadio1:aItems[2]:Disable(), ;
oRad:SetFont ( oFontText ), ;
oRad:nClrText := 255 } )


Image

Best regards
Uwe :)
Last edited by ukoenig on Tue Jun 09, 2015 2:50 pm, edited 1 time in total.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to disable an item of a radio control

Postby Enrico Maria Giordano » Tue Jun 09, 2015 9:08 am

Hua,

please comment out WHEN MyFunc() and it will work fine.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8377
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to disable an item of a radio control

Postby hua » Tue Jun 09, 2015 9:13 am

Gracias Jose. Already tried but didn't work.


Uwe, my self-contained sample has a WHEN clause. I suspect that is what is interfering with manual disable/enable of the item
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1050
Joined: Fri Oct 28, 2005 2:27 am

Re: How to disable an item of a radio control

Postby hua » Tue Jun 09, 2015 9:16 am

Thanks for confirming Enrico. I did suspect that WHEN was the cause.

I may have to come with a workaround that will set bWhen to nil when I want to disable just that one item.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1050
Joined: Fri Oct 28, 2005 2:27 am

Re: How to disable an item of a radio control

Postby ukoenig » Tue Jun 09, 2015 2:46 pm

Your modified sample, using a function on button-action

Image

Code: Select all  Expand view

#include "FiveWin.ch"

FUNCTION MAIN()
local oDlg, oRadMenu
local nOption := 1, oFont, lStatus := .T.

oFont := TFont():New("Arial",0,-14,.F.,.T.,0,0,0,.F. )

DEFINE DIALOG oDlg RESOURCE "Radios"

REDEFINE RADIO oRadMenu VAR nOption ID 110, 120, 130, 140, 150 OF oDlg  
AEval( oRadMenu:aItems, { | oRad | oRad:lTransparent := .T., ;
     oRad:SetFont ( oFont ), ;
     oRad:nClrText := 255 } )

REDEFINE BUTTON ID 100 OF oDlg ;
ACTION ( lStatus := MYFUNC(1), AEval( oRadMenu:aItems, { | oRad | ;
     IIF( lStatus = .T., oRadMenu:aItems[2]:Enable(), ;
               oRadMenu:aItems[2]:Disable() ) } ) )

REDEFINE BUTTON ID 102 OF oDlg ;
ACTION ( lStatus := MYFUNC(2), AEval( oRadMenu:aItems, { | oRad | ;
IIF( lStatus = .T., oRadMenu:aItems[2]:Enable(), ;
              oRadMenu:aItems[2]:Disable() ) } ) )

ACTIVATE DIALOG oDlg CENTERED

oFont:End()

RETURN NIL

// ---------

FUNCTION MYFUNC(nStat)
lValue := .F.

IF nStat = 2
     lValue := .T.
ENDIF

RETURN lValue
 


best regards
Uwe :)
Last edited by ukoenig on Wed Jun 10, 2015 6:32 am, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to disable an item of a radio control

Postby hua » Wed Jun 10, 2015 1:45 am

Thanks Uwe!
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1050
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 43 guests