FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to disable an item of a radio control
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to disable an item of a radio control
Posted: Tue Jun 09, 2015 04:04 AM
Below is the code that I use to test. I couldn't get it to work

Code (fw): Select all Collapse
#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 (fw): Select all Collapse
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
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 05: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!
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 07: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 } )




Best regards
Uwe :-)
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.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 09:08 AM

Hua,

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

EMG

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 09: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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 09: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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable an item of a radio control
Posted: Tue Jun 09, 2015 02:46 PM
Your modified sample, using a function on button-action



Code (fw): Select all Collapse
#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 :-)
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.
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: How to disable an item of a radio control
Posted: Wed Jun 10, 2015 01:45 AM

Thanks Uwe!

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion