Dynamic MDI Menus?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Speed

    Dynamic MDI Menus?

    I am developing an MDI database access app that will be used by people
    with varying access rights. Is it possible to make menu items show or
    be hidden based upon the authority of the user? BTW...the user's
    access level is stored in the db and stored as a public variable upon
    successful authentication.
  • Herfried K. Wagner [MVP]

    #2
    Re: Dynamic MDI Menus?

    * Matthew Speed <mspeed@mspeed. net> scripsit:[color=blue]
    > I am developing an MDI database access app that will be used by people
    > with varying access rights. Is it possible to make menu items show or
    > be hidden based upon the authority of the user? BTW...the user's
    > access level is stored in the db and stored as a public variable upon
    > successful authentication.[/color]

    Yes, thia can be done. What's the problem?

    --
    Herfried K. Wagner [MVP]
    <http://dotnet.mvps.org/>
    Website Address Changed!

    Comment

    • Matthew Speed

      #3
      Re: Dynamic MDI Menus?

      On 29 Feb 2004 14:11:30 +0100, hirf-spam-me-here@gmx.at (Herfried K.
      Wagner [MVP]) wrote:
      [color=blue]
      >* Matthew Speed <mspeed@mspeed. net> scripsit:[color=green]
      >> I am developing an MDI database access app that will be used by people
      >> with varying access rights. Is it possible to make menu items show or
      >> be hidden based upon the authority of the user? BTW...the user's
      >> access level is stored in the db and stored as a public variable upon
      >> successful authentication.[/color]
      >
      >Yes, thia can be done. What's the problem?[/color]

      Okay, I have the MDI app set up. The first thing it does it open a
      child window that asks the user for a login/password. In my _Load sub
      for the MDI parent I have me.menu = nothing so that no menu will show.

      I check against the DB. If they authenticate correctly I close the
      login form and give control to the main MDI form. At this point I
      want the menu to show. Additionally, the permissions for various
      groups of people overlap so what people have access to varies.
      Additionally, I would like to make it so that people who don't have
      access to something don't even know that a particular action exists.


      Comment

      • Peter Huang

        #4
        RE: Dynamic MDI Menus?

        Hi Matthew,

        Thanks for posting in the community.

        From your description, you wants to know how to enable the menu item based
        on the user.

        The code line below will tell you who is the current logon user.
        System.Security .Principal.Wind owsIdentity.Get Current().Name
        Also you can show a form to let the user login into, and you can
        authenticated what access level the user will get and then show the MDI
        Menu, by generating its menu item dynamically.

        Here is some example for dynamically generating the menu.

        frlrfsystemwind owsformsmenucla ssgetmainmenuto pic.asp


        Best regards,

        Peter Huang
        Microsoft Online Partner Support

        Get Secure! - www.microsoft.com/security
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        • Peter Huang

          #5
          Re: Dynamic MDI Menus?

          Hi Matthew,


          After reading your second reply, I think a dynamical MainMenu will be a
          solution.
          In the Form_Load event if MDI form, you can hide the menu item so that it
          will not be found.
          Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
          System.EventArg s) Handles MyBase.Load
          ' Create the MainMenu and the menu items to add.
          Dim mainMenu1 As New MainMenu

          Dim menuItem1 As New MenuItem
          Dim menuItem2 As New MenuItem

          Dim subMenuItem1 As New MenuItem

          ' Set the caption for the menu items.
          menuItem1.Text = "File"
          menuItem2.Text = "Edit"

          'Add an subMenuItem and add its event handler
          subMenuItem1.Te xt = "Test"
          AddHandler subMenuItem1.Cl ick, AddressOf m_Click


          ' Add 3 menu items to the MainMenu for displaying.
          mainMenu1.MenuI tems.Add(menuIt em1)
          mainMenu1.MenuI tems.Add(menuIt em2)

          menuItem1.MenuI tems.Add(subMen uItem1)

          ' Assign mainMenu1 to the form.
          Menu = mainMenu1

          'So that the sencond menu item will not found in the menu bar.
          Menu.MenuItems( 1).Visible = False
          End Sub

          Private Sub m_Click(ByVal sender As Object, ByVal e As System.EventArg s)
          MsgBox("hello")
          End Sub


          If you have any concern on this issue, please feel free to post here.

          Best regards,

          Peter Huang
          Microsoft Online Partner Support

          Get Secure! - www.microsoft.com/security
          This posting is provided "AS IS" with no warranties, and confers no rights.

          Comment

          Working...