Solved

Creating menu bar/items at runtime

Posted on 2000-03-20
9
229 Views
Last Modified: 2010-05-02
Is it possible to create a standard menu bar at the top of the form at runtime and then add menu items to it? If not, is it possible to extend an existing menu bar, also at runtime?
0
Comment
Question by:mi5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 1

Accepted Solution

by:
avitalk earned 60 total points
ID: 2637469
you can't "create" it.
what you need to do is use a control array.

in design time you define one father menu item - mnuItemF.
and then one son - mnuItem
and you give it Index = 0.
you can also use the Visible property as you if you don't want it to be seen.

so at first you have only one menu item.

during run time you can add as many items as you like by:

For i = 1 To iItemNumber
   Load mnuItem(i)
   mnuItem(i).Caption = "Item" & i
Next


also - when you load new controls during run time, they are not visible.
so you'll have to do something like this:

For i = mnuItem.LBound To mnuItem.uBound
    mnuItem(i).Visible = True
Next

hope this helps,
Avital
0
 

Author Comment

by:mi5
ID: 2639666
How do I set which son menu items go under which father items?
0
 
LVL 1

Expert Comment

by:avitalk
ID: 2640427
after you define any menu item you can define sons for it.
son items are define the same way as the father menu, they should be under the father menu in the menu definition window, and you should use the buttons with Left / Right arrows to indicate the
parenthood.

select the son menu item and press the button with the Right Arrow.  that will add 4 points to the son. and that indicates the hierarchy.

for more information try this link:
http://msdn.microsoft.com/library/devprods/vs6/vbasic/vb98/vbrgnmenueditor.htm
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mi5
ID: 2640687
I meant at run time. It is possible to create father menu items at run time - how do I place son items underneath them?
0
 
LVL 1

Expert Comment

by:avitalk
ID: 2641648
I don't think you can do that.
you can add controls to an already existing control array but you can't define a totally new control.

may i ask - why is the solution of control array not good for you ?

Avital
0
 

Author Comment

by:mi5
ID: 2644211
No - they're all in the same control array. If I create new instances of the control array (the son menuItem), how do I move that menu item so it is a sub-menu of a father menuItem (also created from the same array)?
0
 

Author Comment

by:mi5
ID: 2644227
Adjusted points from 50 to 60
0
 

Author Comment

by:mi5
ID: 2644228
In fact - don't worry about it. I've found another way round the problem. Thanks for your help.
0
 
LVL 1

Expert Comment

by:avitalk
ID: 2646280
hmmm, I don't mind helping :-)

let's see if i understand you correctly, you have a father menu item, and the items you want to add during run time are his sons ?

if so then all you need to do is define one son item in design time.  give it an index = 0, and that's the start of the control array.

during run time when you load new menu items to that array, they are automatically, sons of the same father menu, because that's how menu arrays behave.  if you load more items to the array they all stay in the same level.
was that the issue ?

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 56
VB 6 error 5 in windows 10 but not in XP 7 72
pop out of webbrowser1 control vba6 5 51
Fastest way to find and count same items VB6 16 62
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question