Results 1 to 2 of 2

Thread: Hiding menus

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2001
    Location
    UK
    Posts
    205

    Hiding menus

    This is probably easy to solve, but i cant figure it out.

    How do you hide the menu, and when i mean THE menu, i mean as in all the menus at the top of a form.

    I have an MDI form with a menu at the top:

    File Edit Options Window Help

    I just want to hide it or disable it until the user has logged in.

    I was going to do a for loop something like this:
    VB Code:
    1. For Each Menu In Me.Menus
    2.   DoEvents
    3.   Menu.Visible = False
    4.   Menu.Enabled = False
    5. Next

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    The only way I could get this to work, without individually listing each menu item,
    was to put the entire menu in an array. I initially had the same menu structure on
    my test project that I think you have, which is/was:

    mnuFile
    mnuEdit
    mnuOptions
    mnuWindows
    mnuHelp

    I put the menu in an array, by changing the name (The Captions remained File Edit Options Windows Help) of mnuFile, mnuEdit, mnuOptions, mnuWindows, mnuHelp to mnuFile(0) for File, mnuFile(1) for Edit, mnuFile(2) for Options, mnuFile(3) for Windows, mnuFile(4) for Help. Since you don't code the click event of the top level menu items, but rather code the click event of the sub menu items, this doesn't pose a problem, and allows this
    code to work.
    VB Code:
    1. Private Sub Form_Load()
    2. On Error Resume Next
    3. Dim i As Integer
    4.   For i = 0 To mnuFile.Count
    5.      mnuFile(i).Enabled = False
    6.   Next
    7. End Sub
    Hoky? Yeah, a little bit, but it does get the job done without having
    to individually list the various menus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width