How I add a menuitem to a new submenu ?

I have a problem with adding a menuitem to new submenu or new subsubmenu at run time, specially handling the parameters in AppendMenu-API-function and other API-functions for creating menu.

First I created three menuitems in menubar at design time with the menu editor. In the third menubaritem I created a new menuitem, first with index = 0

hMenu0 = GetMenu(Me.hWnd)
hSubMenu0 = GetSubMenu(hMenu0, 2) '2 = Third Menuitem in the menubar
b = AppendMenu(hSubMenu0, MF_POPUP, hMenu1, "1")

Where I find the handling result for going on ? Do I find it in hmenu1 ?
What I have to do with that to add a submenu to the first new added item in this submenu.
Can anyone either point me to some code which shows how to realize it, or maybe indicate what I'm doing wrong.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why so difficult.
You're adding a new menuitem on a submenu. You can do this with creating a Menu control array and using the Load keyword.

You first create a sub-sub menuitem with index 0 menubar at design time with the menu editor.

You can add a new menu item like this

    Dim nNrItems As Integer
    nNrItems = mnuSubSub.Count
    nNrItems = nNrItems + 1
    Load mnuSubSub(nNrItems)
    mnuSubSub(nNrItems).Caption = mnuSubSub(0).Caption & CStr(nNrItems)

You can't do that chengman. There is no way VB can add a submenuitem. He needs to use API's to do so. I'll post an answer in a bit later. I have a code lieing around someplace here.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It seems to work the way you have it, as long as you have at least ONE menu option under the main drop down menu.

What I would suggest is to put at least one menu item under the drop down menu and them use the ModifyMenu API Call to simply modify the first one, then use the AppendMenu to add other menu items.
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

kairaviAuthor Commented:
Please explain, how to use the API-function AppendMenu to add other menu items in a subsubmenu. I have no idear how I set the parameters or handle it.
kairaviAuthor Commented:
You're right. Please post me sample code as quick as possible.
Maybe you send it directly to
My problems begins at run time !
Please explain, how to use the API-function AppendMenu to add other menu items in a subsubmenu. I have no idear how I set the parameters or handle it.
In VB6 (no idea if it works with older versions) you can add menuitems dynamically just the same way as  adding  other controls dynamically.
That means in designtime create a control or menu with index 0 and in runtime add new control or menuitems with the Load command.

I will eat my shoe if it doesn't work

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.