Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding new options to a popup menu from vb6 code 1

Status
Not open for further replies.

elquixiote

Technical User
Nov 30, 2002
99
MX
hi!. I've done some search in the forum trying to found
a way to do new options additions to a popup menu in
vbcode.

Found nothing.

Is that posible?. Can anybody help me?

Thanks...

el Quixiote
 
Create a menu using the Menu Editor then have it pop up like so:


PopUpMenu mnuYourMenu, vbPopUpMenuLeftAlign


"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
If you want to add the option at run time, then, when you create the menu, give it an index (index 0 for example) and that will create a control array (of menu's of course). Then, at run time, you can create new menues (using the Load method). For example, assuming that mnuYourMenu was created at design time and has an index of 0, you could do the following:
Code:
[COLOR=green]' Note index 1[/color]
Load mnuYourMenu(1)
mnuYourMenu(1).Caption = "New Option"
Load mnuYourMenu(2)
mnuYourMenu(2).Caption = "New Option 2"
So, in this case, mnuYourMenu is an array of menu controls, and at run time you simply add elements to this array by using the Load method. Of course, the indexes you use for the new elements must not already exist in the array, otherwise you get a "Control already loaded" error. I ususally just use an integer variable and increment it by one everytime I need to add a new menu control to the array.

Hope this helps!

JC




Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top