Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enabling/disabling menus depending on user rights

Status
Not open for further replies.

zhed0708

IS-IT--Management
Jun 25, 2011
41
PH
plz help me....
i have an vfp project and i want to disable and enable the menus depending on the user type.I have a menus File,Admin,Maintenance,View and Help. And i want to disable menu Admin and maintenance when the user is log in. And enables all the menus if the admin is log in. What shoul i do? plz help me!!!!!

thanx for advance....
 
For each menu bar that you want to disable, add a SKIP FOR clause. This tells VFP to disable the menu bar if a certain condition is true.

For example:

DEFINE BAR .... SKIP FOR lUserRights = .F.

This says to disable the menu bar if the variable lUserRights is .F.

You can disable entire menus or sub-menus in the same way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
i want to disable menu Admin and maintenance when the user is log in.

Mike is correct above.

When the user logs in you must be storing the User Rights to some variable for checking purposes.
Assuming that variable is 'seen' throughout the remainder of your application - whether through a Scope, Object Property, or other means (i.e. PUBLIC) then the menu can also 'see' the variable and use it as Mike as indicated above.

In addition to using the DEFINE BAR command, you can enter the menu pull-down SKIP FOR... expression interactively in the VFP Menu Designer.

Good Luck,
JRB-Bldr
 
thanx for the reply sir...i will try your suggestion and look forward for other suggestions....
 
JRB-Bldr, just for your interest ....

In practice, I have a Security class that knows the permissions of the currently logged-in user. This is instantiated as a global object, and is available throughout the application.

I don't use menu bars much, but I do use command buttons to launch functionality that might be subject to security restrictions. In my base command button class (and certain other classes), I have code that asks the Security object to check the permissions, and to enable or disable the control accordingly.

That way, I can pretty well ignore the whole issue while developing the application. All the security stuff is neatly encapsulated.

Jhedz0708, if you're just starting out in VFP, I suggest you don't take any notice of this reply. Focus on the answers you already have. When you are ready to get to grips with object orientation, take another look. (I hope I'm not talking down to you; if so, my apologies.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top