Results 1 to 12 of 12

Thread: adding to menu during runtime

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    adding to menu during runtime

    how can i make my program add something to a menu bar during runtime?

  2. #2

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    HELP!

    CMON PLEASE

  3. #3
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    You'll need to use API calls. VB creates your menu using those calls.

  4. #4

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    how

    do i do that?

  5. #5
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85
    You don't need to use API calls to dynamically create menu items (or delete them) if you can wait a few hours when I get back from work I will post the code here
    Everytime

    "I'm not normally a religious man, but if you're up there, save me, Superman!" Homer Simpson

    Visit my site

  6. #6

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    if you could just give me an

    idea now, i only have like an hour left

  7. #7

  8. #8
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85
    This is the idea. The specifics might not be right. I am tryiong to check.....

    Adding Menu Controls at Run Time

    A menu can grow at run time. eg menu items are dynamically created to display the path names of the most recently opened files.

    Use the menu editor to create a menu entry that has an index so is part of an array

    You must use a control array to create a control at run time. Because the mnuRecentFile menu control is assigned a value for the Index property at design time, it automatically becomes an element of a control array — even though no other elements have yet been created.

    add an extra menu by load(mnurecentfile)
    delete it by unload(mnurecentfile)

    you can set the mnurecentfile.caption and other properties
    Everytime

    "I'm not normally a religious man, but if you're up there, save me, Superman!" Homer Simpson

    Visit my site

  9. #9
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85
    Sorry about the delay...

    mnuItem is the menu item name created with the menu editor
    In the code i refers to a particular menu item
    Code:
        'To create a menu item
        Load mnuItem (i)
        
        With mnuItem (i)
                .Caption = "open file a"
                .Visible = True
         End With       
        
    
        'unload a menu item to remove it
         Unload mnuItem (i)
    Everytime

    "I'm not normally a religious man, but if you're up there, save me, Superman!" Homer Simpson

    Visit my site

  10. #10

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    i keep getting a error

    Here is my code i want to make an add to favorites for my webbrowser.

    favoritename = InputBox("What Would you like to name your favorite?", "Add Favorite")
    Load mnufavs(i)

    With mnfavs(i)
    .Caption = favoritename
    .Visible = True
    End With


    'unload a menu item to remove it
    Unload mnuitem(i)

  11. #11
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85
    what error do you get?

    Things to check
    1. Have you used the menu editor to create a menu entry that has an index value of 0. Set it to invisible so it cannot be seen yet

    2. When you first want to add a menu item do

    Code:
    with menuitem(0)
        .caption = "test"
        .visible = true
    end with
    when a new entry is required...
    Note that i is a number of a menutiem in the array
    i should be one higher than the number of the last loaded menuitemn

    Code:
    load menuitm(i) 
    
    with menuitem(i)
        .caption = "test entry number " & i 
        .visible = true
    end with
    Everytime

    "I'm not normally a religious man, but if you're up there, save me, Superman!" Homer Simpson

    Visit my site

  12. #12

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Posts
    59

    ok what that does is

    changes the caption on one menu item, i want it to create a new menu item under mnufavs

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