Results 1 to 8 of 8

Thread: how to create sub menu items dynamically

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Cape Town, SA
    Posts
    144

    how to create sub menu items dynamically

    Hi
    I am developing a testing program. I am building a
    menu.The menus caption is "File". It has a sub menu
    called tests. Under tests I want to create sub menus
    dynamically. The caption of the sub menus will be kept in
    the database and i will retreive it at form load and
    then build the sub menus of the test item. Does anyone know how to
    do this?
    thanking you in advance
    PORRASTAR

  2. #2
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    create a submenu with it's index set to 0 and at run time load subsequent menus
    If you have mnuFirstTest as first submenu and its index set to 0 then you can load other menus by

    VB Code:
    1. Load mnuFirstTest(1)
    2. mnuFirstTest(1).Visible = True

  3. #3
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Originally posted by abhid
    create a submenu with it's index set to 0 and at run time load subsequent menus
    If you have mnuFirstTest as first submenu and its index set to 0 then you can load other menus by

    VB Code:
    1. Load mnuFirstTest(1)
    2. mnuFirstTest(1).Visible = True
    As far as I can tell, you have to use API to create Sub Menus. VB lets you do a control array for the 1st levels, but another lower, you need to use... some kinda of API. It was answered a few days ago... but whether they got it working or not, is another question
    Don't Rate my posts.

  4. #4
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    Not quit right.

    It was asked several days ago but there was no controlarray on the form, therefore it needed api to load the menu.

    Here you can load submenu's like abhid mentioned.
    For the first menu set its caption to a seperator -
    and its visible property to false.

    When you load (add) menuItems to it set its visible property to true.
    When loading menu's (objects) at runtime you have to unload them when they are no longer needed (from unload)
    Last edited by swatty; Oct 16th, 2002 at 05:08 AM.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    There are literally loads of threads on this forum which will detail exactally what you want to do, using techneques from menu arrays, external menu controls and API...

    Just do a search for "add menus at runtime", or something along those lines...

    Regards,

    Woka

  6. #6
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    How is that meant to work?

    You can't have sub menu items if the 1st item is invisible.
    Don't Rate my posts.

  7. #7
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Here's a test project I have been working on. Nowhere near complete yet, but it may help you with your menus as it creates menus at runtime using API...
    This example is actually supposed to be for adding items into the SysTray, but it has code in it to create menus...
    If you right click on the World icon it adds to the systray you can see the menu that pops up...

    Hope this helps...
    Woka

    PS Load the group project and run...
    Attached Files Attached Files

  8. #8

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