Page 1 of 1

Update Menu on MDI frame ?

PostPosted: Tue Nov 27, 2007 10:58 pm
by Rick Lipkin
To All

I have the main MDI menu and on that menu is an option to 'login as a different user'. In the login process .. public variables are changed and based on those changes .. the Menu options need to change.

I am looking for a way to refresh or update the MDI menu options when I complete the login process .. see code in BuildMenu function ..

//--------------------------//
Static FUNCTION BuildMenu( xDEFA, dEXE, cRDD,nSCR1,nSCR2 )

LOCAL oMenu

MENU oMenu

MENUITEM "&Trips, Dispatch, Gas and CVRP Entry ..." // ;
* ACTION _tripmenu( oWIND ) ;
* MESSAGE "TRIPS Data Entry"

MENUITEM "&Vehicles\Equip\Boats ..." ;
ACTION _vehbrow( oWIND ) ;
MESSAGE "Vehicle, Equipment and Boat Information"

MENUITEM "&Maintenance ..." // ;
* ACTION _mantmenu( oWIND ) ;
* MESSAGE "Work Orders"

MENUITEM "&Reports ..." // ;
* ACTION _RPTmenu( oWIND ) ;
* MESSAGE "Report Menu"

MENUITEM "&Utilities..." ;
ACTION _UTILmenu( oWIND ) ;
MESSAGE "Utilities Programs"

IF xADMIN = 'Y'
MENUITEM "&Login Diff User .." ;
ACTION( _Log_in(), ;
cRIGHTS := _Rights(), ;
xMESSAGE := ("User "+xLOGIN+" Rights "+cRIGHTS+ ;
" Default= "+xDEFA+" Rdd= "+cRDD+ ;
" Revision "+DTOC(dEXE)+;
" Agency\Mp= "+ALLTRIM(xAGENCY)+"\"+alltrim(xPOOL)+;
" -r"+str(nSCR1,4)+" x "+STR(nSCR2,4)),;
oWind:oMsgBar := TMsgBar():New(oWind,xMESSAGE,.F.,.T.,.F.,.F.,,,,),;
oWind:ReFresh(),;
MsgInfo( "Current User is now "+xLOGIN ),;
SysReFresh() ) ;
MESSAGE "Login as a different User"

MENUITEM "&Change Agency .." ;
ACTION( _ChgAgen(), ;
cRIGHTS := _Rights(), ;
xMESSAGE := ("User "+xLOGIN+" Rights "+cRIGHTS+ ;
" Default= "+xDEFA+" Rdd= "+cRDD+ ;
" Revision "+DTOC(dEXE)+;
" Agency\Mp= "+ALLTRIM(xAGENCY)+"\"+alltrim(xPOOL)+;
" -r"+str(nSCR1,4)+" x "+STR(nSCR2,4)),;
oWind:oMsgBar := TMsgBar():New(oWind,xMESSAGE,.F.,.T.,.F.,.F.,,,,),;
oWind:ReFresh(),;
MsgInfo( "Current Agency\MP is now "+alltrim(xAGENCY)+"\"+alltrim(xPOOL )),;
SysReFresh() ) ;
MESSAGE "Change Agency and Motorpool"
ENDIF

MENUITEM "&About .." ;
ACTION _webhelp( xDEFA,dEXE ) ;
MESSAGE "Version Information"

MENUITEM "&Quit" ;
ACTION oWIND:END() ;
MESSAGE "End this Program"

ENDMENU

RETURN( oMenu )



Login different user and change Agency menu options need to be hidden if the public var xADMIN is not "Y" .. after the manual login

Rick Lipkin
SC Dept of Health, USA

PostPosted: Wed Nov 28, 2007 5:12 am
by James Bott
Rick,

How about just destroying and then rebuilding the menu?

oWnd:SetMenu( BuildMenu(...) )

James

PostPosted: Wed Nov 28, 2007 12:54 pm
by Rick Lipkin
James

Did not work .. here is the code snipit I inserted :

IF xADMIN = 'Y'
MENUITEM "&Change Agency .." ;
ACTION( _ChgAgen(), ;
cRIGHTS := _Rights(), ;
xMESSAGE := ("User "+xLOGIN+" Rights "+cRIGHTS+ ;
" Default= "+xDEFA+" Rdd= "+cRDD+ ;
" Revision "+DTOC(dEXE)+;
" Agency\Mp= "+ALLTRIM(xAGENCY)+"\"+alltrim(xPOOL)+;
" -r"+str(nSCR1,4)+" x "+STR(nSCR2,4)),;
oWind:oMsgBar := TMsgBar():New(oWind,xMESSAGE,.F.,.T.,.F.,.F.,,,,),;
oWind:ReFresh(),;
MsgInfo( "Current Agency\MP is now "+alltrim(xAGENCY)+"\"+alltrim(xPOOL )),;
oWind:SetMenu( BuildMenu( xDEFA, dEXE, cRDD,nSCR1,nSCR2 )),;
SysReFresh() ) ;
MESSAGE "Change Agency and Motorpool"
ENDIF

PostPosted: Wed Nov 28, 2007 2:23 pm
by Antonio Linares
Rick,

Make a call to oWnd:oMenu:End() before doing oWnd:SetMenu( ... )

PostPosted: Wed Nov 28, 2007 3:13 pm
by Rick Lipkin
James and Antonio

YES ... I needed both of your suggestions !!!!!!!!! Works perfectly !!!

Thanks
Rick Lipkin