disable/enable button

disable/enable button

Postby Silvio.Falconi » Fri Jul 12, 2019 10:13 am

how disable /enable a button on ribbonbar?

with

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

not run, so this is the error

Code: Select all  Expand view  RUN
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 )
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Postby ukoenig » Fri Jul 12, 2019 10:31 am

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.

viewtopic.php?f=3&t=22737&p=121478&hilit=image+to+gray#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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: disable/enable button

Postby Silvio.Falconi » Fri Jul 12, 2019 1:15 pm

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()
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Postby ukoenig » Fri Jul 12, 2019 1:52 pm

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: disable/enable button

Postby Silvio.Falconi » Fri Jul 12, 2019 4:02 pm

sorry but not run Please see this test
Code: Select all  Expand view  RUN

#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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: disable/enable button

Postby Silvio.Falconi » Fri Jul 12, 2019 4:34 pm

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  Expand view  RUN

#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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