Real time menu editing

Simple app to add and remove things from the "menu editor" menu in real time (whilst the program is running); the example below simply counts to ten, but you can do various things with this concept.

All you need is a bit of knowledge on the "Menu Editor"

Open menu editor (Ctrl+E)

Create a menu with the following attributes

Name : MnuFile

Caption : File

Now add a sub-menu to it with the following

Caption : SpaceSaver

Name : MnuRealTime

Index : 0

whoops

 

Make sure you set the index of the sub menu. This is important.

Now... Add two buttons with the following attributes

First Command Button:

Name : CmdAdd10

Caption : Count To 10



Second Command Button:

Name CmdRemoveAll

Caption : Remove All

 

The form should look something like this

whoops

 

Now goto the code for CmdAdd10:

 

Private Sub cmdAdd10_Click()

Dim i As Integer

For i = 1 To 10

Load mnuRealTime(i)                                '  this loads a new menu item

mnuRealTime(i).Caption = i                     ' this changes its caption

Next

mnuRealTime(0).Visible = False              ' this makes the spacesaver invisible

End Sub

 

Next add this code to the cmdRemoveAll click event

Private Sub cmdRemoveAll_Click()
Dim i As Integer
mnuRealTime(0).Visible = True                 'this makes the spacesaver visible again
For i = 1 To mnuRealTime.ubound          ' deletes all items except 0 which is the spacesaver
Unload mnuRealTime(i)                           'unloads the menu item
Next
End Sub


Run the program and Wallaaaaaaaaaa

You can use this for a lot of things... For example favourites on a web browser or recently opened files on an office type application

Good luck and have fun

If you need help just ask!

You might also like...

Comments

Adam Gunning

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous