FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Menu and buttonbar When clause
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Menu and buttonbar When clause
Posted: Mon Sep 12, 2016 10:08 AM
Hi,
If I click on menu I can modify When clause only in menu and not in Buttonbar.
The same thing happens in buttonbar.
The question is: How can I act both on the menu and on the button bar?
lAccess is a Local variable and the user can use either the menu or button bar
King regards
Marco


Code (fw): Select all Collapse
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oMain
LOCAL oMenu
LOCAL oBar
LOCAL lAccess
LOCAL oBtnLogin, oBtnLogout
LOCAL oBtnList
lAccess := .F.

DEFINE MENU oMenu
MENU oMenu 2007

  MENUITEM "&Login"

     MENU 2007
        MENUITEM "&Login- lAccess = True"    ACTION lAccess := .T.
        MENUITEM "&Login- lAccess = False"   ACTION lAccess := .F.
        MENUITEM "List"                      ACTION MsgInfo( laccess ) WHEN lAccess
     ENDMENU

ENDMENU


DEFINE WINDOW oMain FROM 100 , 100 TO 500 , 500 PIXEL  MENU oMenu
DEFINE BUTTONBAR oBar OF oMain SIZE 100, 100 2007

DEFINE BUTTON oBtnLogin   OF oBar PROMPT "&Login- lAccess = True"     ACTION lAccess := .T.
DEFINE BUTTON oBtnLogout  OF oBar PROMPT "&Logout- lAccess = False"   ACTION lAccess := .F.
DEFINE BUTTON oBtnList    OF oBar PROMPT "&List"   WHEN lAccess ACTION MsgInfo( "LIST" )




ACTIVATE WINDOW oMain

RETURN NIL
Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Menu and buttonbar When clause Solved
Posted: Mon Sep 12, 2016 10:28 AM
Maybe in this way?
Thanks a lot
Marco

ACTION ( lAccess := .T. , oBar:AevalWhen() )

....
....
ACTION ( lAccess := .T. , oMenu:Refresh() )
Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menu and buttonbar When clause
Posted: Mon Sep 12, 2016 04:45 PM

Marco,

Yes, that should work

Have you tested it ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Menu and buttonbar When clause
Posted: Tue Sep 13, 2016 07:13 AM

Antonio,
Yes
Thank You

Marco Boschi
info@marcoboschi.it
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Menu and buttonbar When clause
Posted: Fri Sep 16, 2016 03:25 PM
Code (fw): Select all Collapse
function DynamicMenuBar

   LOCAL oMain
   LOCAL oMenu
   LOCAL oBar, oBtn

   DEFINE MENU oMenu
   MENU oMenu 2007

      MENUITEM "&Login"

      MENU 2007
         MENUITEM "&Login"  ;
            WHEN { |o| o:SetPrompt( If( lAccess, "&LogOut", "&LogIn" ) ), .t. } ;
            ACTION lAccess := !lAccess
         MENUITEM "List" ACTION MsgInfo( lAccess ) WHEN lAccess
      ENDMENU

   ENDMENU

   DEFINE WINDOW oMain FROM 100 , 100 TO 500 , 500 PIXEL  MENU oMenu
   DEFINE BUTTONBAR oBar OF oMain SIZE 100, 64 2007

   DEFINE BUTTON oBtn OF oBar FILE "c:\fwh\bitmaps\bottom1.bmp","c:\fwh\bitmaps\top1.bmp" ;
      PROMPT { || oBtn:lPressed := lAccess, If( lAccess, "&Logout", "&Login" ) } ;
      ACTION ( lAccess := !lAccess, This:Toggle() )

   DEFINE BUTTON OF oBar PROMPT "&List"  CENTER WHEN lAccess ACTION MsgInfo( "LIST" )

   ACTIVATE WINDOW oMain CENTERED

return nil
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion