Re: [Win32Lib] How add/remove MENU ITEMS "on the fly"?
- Posted by Mario Steele <eumario at trilake.net> Mar 07, 2005
- 500 views
Hey Daniel, Well, this is somewhat a simple solution. It comes to the point of two possible answers that you can follow, to make it work. The first method, is to staticly create the Menu Items under all of the Menus, then use setVisible() to hide, and show thoes items that the User Selects. That's Method one. Method Two, is to store a list of Menu Items in a Sequence, which should look something like this:
constant MenuArch = { {ID_FILE,"&New",ID_NEW}, {ID_FILE,"E&xit",ID_EXIT}, {ID_EDIT,"&Cut",ID_CUT}, {ID_EDIT,"C&opy",ID_COPY}, {ID_EDIT,"&Paste",ID_PASTE} }
This way, you have your Basic Structure of where items will go, and drop them in there fairly easy. Then you can dynamically have a sequece list of the actual item id's, so you can delete them. You wouldn't need it for anything else, cause you can simply use setHandler() to add the w32HClick event to the Menu Item, when you create the control. Other then that, it's fairly easy. Any Win32 Control can be created multiple times, with the same definition, as long as you can get a Unique ID to identify it from others. BTW, there will be one more option you can use, which is to use SOOP to handle it. You can have a simple sequence in the main "Menu" class, which holds all of the Menu's, and Sub-Menus, then create a "MenuItem" class, in which to classified everything, and structure your routines as such. It's pretty much how you will do it now, with Normal Euphoria, but offers a more structured way of doing things, since you can Inherit from a parent class, and have everything run the same exact way, only with your own customizable Routines. This will be one of the Win32lib Demos I will do for SOOP 1.0 Hope this helps, Mario Steele http://enchantedblade.trilake.net Attaining World Dominiation, one byte at a time...