Re: programming menus

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I might as well chime in with my own comments (inline...)


"Rick" <Rick@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
Hi,
When programming the visible properties for all the menus in an application
(in VB6) I get an error when I tell the system to turn off all the submenus
from a particular parent menu.


First thing I'd mention is to take a look at menus from user programs
supplied with Windows. (eg, Explorer, IE, Outlook Ex. etc) and notice
there are VERY FEW menus that are more than two levels deep. The
menu bar, and its drop-down list of menus is the norm. On RARE
occasion there is a third level, and TYPICALLY that third level is
used to select an option related to the second level menu item.

Even if all the option items are disabled, or the third level is empty
(with an [empty] place holder) the second level menu item is not
disabled.

I don't know your specific application needs, but you should
consider that MS has done a bit of research in usability, and that
is what they've used for their programs.



Is there a way to tell the system to turn off the parent menu when all the
submenus become unvisible?

The situation is to be able to paratrize the visible aspect of an
application according to certain user-dependent parameters.


I am not sure what 'paratrize' means (he he) but it sounds like you
have an application targeted at users in different roles, or at different
security levels. If you have escelating access levels, where each level
has access to what the lower levels have plus what's at their own level,
you might simply assign an access level to all your menues (in the Tag
property) such as 0 for everybody, 1 for supervisors, 2 for managers,
and so on, and when starting up, simply run through all the menus
(found in Controls collection) setting them visible according to the
current user's access level.

Ex:
If Val(menu.Tag) <= UserAccess Then menu.Visible = True

Or the simpler form:

menu.Visible = CBool( Val(menu.Tag) <= UserAccess)


If you have more of a roles (mix and match) situation, like the
security permissions allowed for file access in Windows, you could
use bitwise masking for the values in the Tag property, and again,
loop at startup to set the visible properties.

Example of Bit masking

1 = production
2 = marketing
4 = accounting
8 = security
16 = general admin
32 = executive admin
... etc

So that a person who has access to production and security menus
needs an access token of 9 (1 OR 8). And a person in marketing
with permmision for gen. and exec. admin would need a token of
50 (2 OR 16 OR 32). So then:

token = Val(menu.Tag)
If (token And UserAccess) = token Then menu.Visible = True

You can find all the menus in your application (at startup) by
looping through the Controls collection

For Each menu In Controls
If TypeOf menu Is Menu Then
' ... work with menu tag
End if
Next

Might something like that work for you?

LFS


.



Relevant Pages

  • Show Built-in Toolbars for selected people
    ... I have a Access 2002 database with several levels of security access. ... Design) for the admin users (these are not owners or developers of the ... and menus in the switchboard load code, manually, then turn the Query ...
    (microsoft.public.access.formscoding)
  • Re: Creating a link on the homepage
    ... In the Web Access go to Admin -> Server Configuration -> Menus and then "Add ... "EJW" wrote in message ...
    (microsoft.public.project.pro_and_server)
  • sourcesafe
    ... I log into visial sourcesafe as ... 'admin' and I'am missing some menus, like adding users.What do I do wrong? ...
    (microsoft.public.dotnet.languages.csharp)
  • Word/Excel 2007 - do people like the ribbon
    ... Isn't the new ribbon at the top confusing for less advanced users? ... for admin people who are used to the old menus. ... Can you switch from the new ribbon to the old style of menus? ...
    (microsoft.public.office.misc)
  • Access Menus
    ... them away once you have taken away the toolbar to get to ... security other than just unchecking the different menus. ...
    (microsoft.public.access.security)