Update Menu on MDI frame ?

Update Menu on MDI frame ?

Postby Rick Lipkin » Tue Nov 27, 2007 10:58 pm

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
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby James Bott » Wed Nov 28, 2007 5:12 am

Rick,

How about just destroying and then rebuilding the menu?

oWnd:SetMenu( BuildMenu(...) )

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Rick Lipkin » Wed Nov 28, 2007 12:54 pm

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
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Antonio Linares » Wed Nov 28, 2007 2:23 pm

Rick,

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

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

Postby Rick Lipkin » Wed Nov 28, 2007 3:13 pm

James and Antonio

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

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

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