how can i make my program add something to a menu bar during runtime?
Printable View
how can i make my program add something to a menu bar during runtime?
CMON PLEASE
You'll need to use API calls. VB creates your menu using those calls.
do i do that?
You don't need to use API calls to dynamically create menu items (or delete them) if you can wait a few hours when I get back from work I will post the code here
idea now, i only have like an hour left
Or try searching the followin sites:
http://www.allapi.net/
http://vb-world.net/api/
http://visualbasic.about.com/library...htm?once=true&
This is the idea. The specifics might not be right. I am tryiong to check.....
Adding Menu Controls at Run Time
A menu can grow at run time. eg menu items are dynamically created to display the path names of the most recently opened files.
Use the menu editor to create a menu entry that has an index so is part of an array
You must use a control array to create a control at run time. Because the mnuRecentFile menu control is assigned a value for the Index property at design time, it automatically becomes an element of a control array — even though no other elements have yet been created.
add an extra menu by load(mnurecentfile)
delete it by unload(mnurecentfile)
you can set the mnurecentfile.caption and other properties
Sorry about the delay...
mnuItem is the menu item name created with the menu editor
In the code i refers to a particular menu item
Code:'To create a menu item
Load mnuItem (i)
With mnuItem (i)
.Caption = "open file a"
.Visible = True
End With
'unload a menu item to remove it
Unload mnuItem (i)
Here is my code i want to make an add to favorites for my webbrowser.
favoritename = InputBox("What Would you like to name your favorite?", "Add Favorite")
Load mnufavs(i)
With mnfavs(i)
.Caption = favoritename
.Visible = True
End With
'unload a menu item to remove it
Unload mnuitem(i)
what error do you get?
Things to check
1. Have you used the menu editor to create a menu entry that has an index value of 0. Set it to invisible so it cannot be seen yet
2. When you first want to add a menu item do
when a new entry is required...Code:with menuitem(0)
.caption = "test"
.visible = true
end with
Note that i is a number of a menutiem in the array
i should be one higher than the number of the last loaded menuitemn
Code:
load menuitm(i)
with menuitem(i)
.caption = "test entry number " & i
.visible = true
end with
changes the caption on one menu item, i want it to create a new menu item under mnufavs