Menu and buttonbar When clause

Menu and buttonbar When clause

Postby MarcoBoschi » 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: Select all  Expand view
#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
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Menu and buttonbar When clause Solved

Postby MarcoBoschi » 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() )
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Menu and buttonbar When clause

Postby Antonio Linares » Mon Sep 12, 2016 4:45 pm

Marco,

Yes, that should work

Have you tested it ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Menu and buttonbar When clause

Postby MarcoBoschi » Tue Sep 13, 2016 7:13 am

Antonio,
Yes
Thank You
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Menu and buttonbar When clause

Postby nageswaragunupudi » Fri Sep 16, 2016 3:25 pm

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Natter and 45 guests