disable/enable button

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

disable/enable button

Post by Silvio.Falconi »

how disable /enable a button on ribbonbar?

with

oBtn[16]:Disable()
oApp:oRebar:refresh()

not run, so this is the error

Code: Select all

Application
===========
   Path and name: C:\Users\silvio\Desktop\Release_TPlan\Fsdi_tdatabase\main.Exe (32 bits)
   Size: 6,966,272 bytes
   Compiler version: Harbour 3.2.0dev (r1904111533)
   FiveWin  version: FWH 19.05
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 31 secs 
   Error occurred at: 12-07-2019, 12:17:22
   Error description: Error BASE/1004  Metodo non disponibile: DISABLE
   Args:
     [   1] = U   

Stack Calls
===========
   Called from:  => DISABLE( 0 )
   Called from: source\main_.prg => PLANNING( 1117 )
   Called from: source\main_.prg => (b)TAPPLICATION_BUILDRIBBONBAR( 852 )
   Called from: .\source\classes\TRBTN.PRG => TRBTN:CLICK( 717 )
 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: disable/enable button

Post by ukoenig »

Silvio,

I noticed that buttons ( disabled ) are not shown in gray-style

I tested :

@ 25, 10 ADD BUTTON oBtn36 GROUP oGr6 BITMAP "..\Sytem\Exit.bmp" ;
SIZE 70, 50 PROMPT "Exit" MOSTLEFT round ;
action oWnd:End()
oBtn36:LoadBitmaps( ".\bitmaps\Exit1.png" ) // normal

disabled :

oBtn36:Disable()
oBtn36:SetFile( ".\bitmaps\Disabled.bmp" ) // gray image


it means a extra image is needed.

http://forums.fivetechsupport.com/viewt ... ay#p121478

I will have a look at gdiplus :

CLASS GDIBmp
DATA hBmp
...
...
METHOD ConverToGray() INLINE ::hBmp := GdiPlusImageMatrixToGray( ::hBmp )

METHOD SetColorGrayPix( nX, nY ) INLINE GdiPlusImagePixToGrayColor( ::hBmp, nX, nY )

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.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Post by Silvio.Falconi »

Uwe,do you saw the error.log
it not found disable method...
then the gray button is another question gurus must be resolve
i have error when i made obtn[16]:DISABLE()
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: disable/enable button

Post by ukoenig »

Silvio,

No error
tested with original sample < ribbon2.prg >
The image doesn't change.

Image

ADD GROUP oGr1 RIBBON oRBar TO OPTION 1 PROMPT "Font" WIDTH 205
@ 10, 05 ADD BUTTON oBtn5 GROUP oGr1 BITMAP "..\bitmaps\bold16.bmp" GROUPBUTTON FIRST SIZE 25, 20 ROUND ;
ACTION( oBtn5:lSelected := !oBtn5:lSelected )
oBtn5:Disable()

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.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Post by Silvio.Falconi »

sorry but not run Please see this test

Code: Select all

 
#include "fivewin.ch"
#include "ribbon.ch"


function main()

   local oRBar
   local oWnd
   local oGr
   local oBtn:=array(20)

    DEFINE WINDOW oWnd TITLE "RibbonBar Test " + FWVERSION from 1,1 to 600,600 pixel //brush oBrush1

   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25
   


  ADD GROUP oGr RIBBON oRBar TO OPTION 1 PROMPT "test disable" width 130 
 

@ 2,5   ADD BUTTON oBtn[16] PROMPT "Planner" ;
                  BITMAP "TOOLBAR_PLANNER"         ;
                  GROUP oGr ROUND SIZE 72,72;
                  ACTION  (oBtn[16]:lSelected := !oBtn[16]:lSelected,;
                  IIF(oBtn[16]:lSelected, myProcedure(),))



   ACTIVATE WINDOW oWnd MAXIMIZED
   
   oRBar:End()
   
return nil

//------------------------------------------------------------------------------------------------//
Function myProcedure( )

Local oWndMio

 DEFINE WINDOW oWndMio TITLE "my procedure "
 ACTIVATE WINDOW oWndMio
    return nil
 

tried also with ACTION (obtn[16]:DISABLE(),oBtn[16]:lSelected := !oBtn[16]:lSelected,;
IIF(oBtn[16]:lSelected, myProcedure(),))

it is disable but then how I can make o enable the button at the end of my procedure ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Post by Silvio.Falconi »

Uwe,
in this test there is a solution but I think is not good because I must use Memvar

Static oItem[90], oBtns[20]

oItem for disable/enable menuitem

oBtns for disable/enable buttons

on function Perform we can insert also the possibilty to check if the user have the authorization to open that procedure

Code: Select all

 
#include "fivewin.ch"
#include "ribbon.ch"

Static oItem[90], oBtns[20]     // Menu and buttons

MemVar oMOpc, oBBar

function main()

   local oRBar
   local oWnd
   local oGr

    DEFINE WINDOW oWnd TITLE "RibbonBar Test " + FWVERSION from 1,1 to 600,600 pixel //brush oBrush1

   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25
   


  ADD GROUP oGr RIBBON oRBar TO OPTION 1 PROMPT "test disable" width 130


@ 2,5   ADD BUTTON oBtns[16] PROMPT "Planner" ;
                  BITMAP "TOOLBAR_PLANNER"         ;
                  GROUP oGr ROUND SIZE 72,72;
                 ACTION Perform("MyProcedure()",oItem[ 2],oBtns[ 16])

   ACTIVATE WINDOW oWnd MAXIMIZED

   oRBar:End()

   return nil
//----------------------------------------------------------------//
FUNCTION Perform(cModulo,oItem,oBtnB)

   DEFAULT oItem:=NIL
   DEFAULT oBtnB:=NIL

    oMOpc:=oItem
    oBBar:=oBtnB


  IF !Empty(oItem)
      oItem:Disable()
   ENDIF
   IF !Empty(oBtnB)
      oBtnB:Disable()
   ENDIF

         CursorWait()
         bX:={|| &cModulo}
         Eval(bX)
         Memory(-1)
         Sysrefresh()
         CursorArrow()

   return nil




//------------------------------------------------------------------------------------------------//


Function MyProcedure()
LOCAL oItem:=oMOpc, oBtnB:=oBBar

Local oWChld

DEFINE WINDOW oWChld TITLE "my procedure "


 ACTIVATE WINDOW oWChld ;
      VALID     (oWChld:=Nil,Close(oItem,oBtnB) ,.T.)
 return nil


//-------------------------------------------------------------//
 STAT FUNC Close(oItem,oBtnB)

    oBtnb:Enable()
   * oItem:Enable()
RETURN (.T.)

 


you could create two archives: one with the list of all the program's modules and another with the permissions of all users. So from the Perform function you could check first if the module is active and then if even the current user has permission to access that module.

There are two advantages

By doing so we are not forced to insert the modules into the source, that is to say the procedures even if we have not yet created them

When I create a new module and compile it into the application I go to insert a flag in the modules archive

and then the perform () function

could return a message with "the module is not available" if it does not find that flag so for not having the error "function not found" in compilation

and at the same time stop that user who does not have access to that module "the user does not have access to this module"



but between saying and doing there is always the sea ... it was just an idea !!!! :D
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply