Click here to Skip to main content
16,020,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Let's say I change the number of menu items at one point, and I need to know the number of menus left. I am thinking of a function that would go through the top menu (hMenu) and loop through the entire menu(including submenus), increases a variable accordingly, and breaks out of the loop when a 0 is hit (or when there are no menu items left).

Anyone has any idea how to do this? Thanks in advance.
Posted
Updated 28-Jun-10 4:59am
v2

1 solution

I wrote an article (for C++) that might be of help. It retrieved menu items from a database and built the entire menu structur for a desktop application from the retrieved menu items. It may help you come up with a design, so here it is:

Dynamically Build Your Menu and/or Toolbar[^]

The key is having your table structure adequately defined to alow for sub menus. I used a numeric menu id for every menu item, and each database record had a column for ParentID so I could associate a menu item with it's parent. A ParentID of 0 indicated a top-lovel menu item.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900