Creating Menus, Submenus and Menuitems at runtime

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

    Creating Menus, Submenus and Menuitems at runtime

    Hi Everybody,

    This is the first timw I am entering into this Group.

    I am developing a VB Project with an MDI form.

    I want to display IE Favorites into my application. For this I need to
    create Submenus and Menuitems dynamically. It is possible to create
    menus using array index. But if I have multiple folders and files in
    Favorites then using array index will not work.

    Can anyone in this group help me ?

    I need source code with an example.

    Thanks & Regards
    Venkatesh
  • Randy Birch

    #2
    Re: Creating Menus, Submenus and Menuitems at runtime

    : I want to display IE Favorites into my application. For this I need to
    : create Submenus and Menuitems dynamically. It is possible to create
    : menus using array index.

    Somewhat. In order to create a dynamic menu in VB you must have at least one
    member already created at design time. The remaining items are added via the
    Load statement, just as with control arrays. This means that to have a menu
    that displays sublevels under main items (ie Favorites > Microsoft >
    Development and Favorites > Microsoft > Office), you have to have an empty
    template under the Favorites and Microsoft items. If the Office folder
    contains Office > Word, Office> Excel and Office > Frontpage, then you will
    need to have constructed your design time menu with a blank item at this new
    sub level. IOW, if the favorites folder contains items n levels deep, your
    app has to have blank items n items deep in order to display the menu as it
    would appear in IE.

    And from what I can see in a quick scan of the MSDN, VB's Control.Add()
    method, which provides for adding new controls at runtime without the need
    for a template item, is not applicable to menus.


    : But if I have multiple folders and files in
    : Favorites then using array index will not work.

    It is possible to do this (the above) using Windows API, then attaching the
    menu to the app, however the VB form will be unaware it has a menu and all
    coding for detection of the user's selection would need to be made through
    subclassing.

    Many VB apps I've seen that require such dynamic menu functionality,
    especially for favorites, have resorted to using other controls such as a
    treeview displayed in response to a toolbar item click. Not a perfect
    solution however.


    --

    Randy Birch
    MVP Visual Basic

    Please respond only to the newsgroups so all can benefit.


    "Venkatesh" <mvenkatesh_kum ar@hotmail.com> wrote in message
    news:c744a4fa.0 311102129.17b7f 50c@posting.goo gle.com...
    : Hi Everybody,
    :
    : This is the first timw I am entering into this Group.
    :
    : I am developing a VB Project with an MDI form.
    :
    : I want to display IE Favorites into my application. For this I need to
    : create Submenus and Menuitems dynamically. It is possible to create
    : menus using array index. But if I have multiple folders and files in
    : Favorites then using array index will not work.
    :
    : Can anyone in this group help me ?
    :
    : I need source code with an example.
    :
    : Thanks & Regards
    : Venkatesh


    Comment

    Working...