One sub handling multiple menu items 
Author Message
 One sub handling multiple menu items

I've had to setup some menu items (website links) to be
created at run time.  Because of this there is an
undefined amount of menu items and so I can't set them
all up with their own sub.  What I'm wondering is how to
differentiate which menu item was clicked and forced the
sub to be called.  Calling the website will be easy from
there because they are placed in an array.  However I've
tried to find out how to tell which menu item was clicked
and unfortunately I can't at this point.  Any help would
be greatly appreciated.

Shuesty



Sun, 05 Jun 2005 22:13:31 GMT  
 One sub handling multiple menu items
The first parameter to the event handler should be an object - this is the
object that caused the event to fire. You should cast it to the appropriate
data type to mainpulate it.


Quote:
> I've had to setup some menu items (website links) to be
> created at run time.  Because of this there is an
> undefined amount of menu items and so I can't set them
> all up with their own sub.  What I'm wondering is how to
> differentiate which menu item was clicked and forced the
> sub to be called.  Calling the website will be easy from
> there because they are placed in an array.  However I've
> tried to find out how to tell which menu item was clicked
> and unfortunately I can't at this point.  Any help would
> be greatly appreciated.

> Shuesty



Mon, 06 Jun 2005 04:24:11 GMT  
 One sub handling multiple menu items
Inherit the menuitem class and add an index property, so you know which
menuitem was clicked.
or
convert the sender object to a menu item and use the text property.


Quote:
> I've had to setup some menu items (website links) to be
> created at run time.  Because of this there is an
> undefined amount of menu items and so I can't set them
> all up with their own sub.  What I'm wondering is how to
> differentiate which menu item was clicked and forced the
> sub to be called.  Calling the website will be easy from
> there because they are placed in an array.  However I've
> tried to find out how to tell which menu item was clicked
> and unfortunately I can't at this point.  Any help would
> be greatly appreciated.

> Shuesty



Mon, 06 Jun 2005 11:55:42 GMT  
 One sub handling multiple menu items
Can we back up a bit please.

The MenuItem class already has an Index property.

<from documentation>
    Gets or sets a value indicating the position of the menu item in its
parent menu.

Whe you set them up at runtime, what about adding a handler for the click
event of all of them, then in the sub do summat like:

    execute code using link(ctype(sender,menuitem).index

assuming of course that all the menuitems concerned belong to the same
parent and that they were added in the same order as the url's were added to
the array.


Quote:
> Inherit the menuitem class and add an index property, so you know which
> menuitem was clicked.
> or
> convert the sender object to a menu item and use the text property.



> > I've had to setup some menu items (website links) to be
> > created at run time.  Because of this there is an
> > undefined amount of menu items and so I can't set them
> > all up with their own sub.  What I'm wondering is how to
> > differentiate which menu item was clicked and forced the
> > sub to be called.  Calling the website will be easy from
> > there because they are placed in an array.  However I've
> > tried to find out how to tell which menu item was clicked
> > and unfortunately I can't at this point.  Any help would
> > be greatly appreciated.

> > Shuesty



Mon, 06 Jun 2005 12:54:54 GMT  
 One sub handling multiple menu items
Sorry, Itemdata not index, not thinking today.  This way it doesn't matter
if it is a child menuitem or sub item etc

Quote:
> Can we back up a bit please.

> The MenuItem class already has an Index property.

> <from documentation>
>     Gets or sets a value indicating the position of the menu item in its
> parent menu.

> Whe you set them up at runtime, what about adding a handler for the click
> event of all of them, then in the sub do summat like:

>     execute code using link(ctype(sender,menuitem).index

> assuming of course that all the menuitems concerned belong to the same
> parent and that they were added in the same order as the url's were added
to
> the array.



> > Inherit the menuitem class and add an index property, so you know which
> > menuitem was clicked.
> > or
> > convert the sender object to a menu item and use the text property.



> > > I've had to setup some menu items (website links) to be
> > > created at run time.  Because of this there is an
> > > undefined amount of menu items and so I can't set them
> > > all up with their own sub.  What I'm wondering is how to
> > > differentiate which menu item was clicked and forced the
> > > sub to be called.  Calling the website will be easy from
> > > there because they are placed in an array.  However I've
> > > tried to find out how to tell which menu item was clicked
> > > and unfortunately I can't at this point.  Any help would
> > > be greatly appreciated.

> > > Shuesty



Tue, 07 Jun 2005 06:30:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. menus and sub-menus and sub-sub-menus

2. Creating New menu and sub menu items all through code

3. Finding and Acting Upon Sub Menu Items In a Menu

4. Handling errors through multiple Sub calls

5. Sub Menu Item in Word 2k

6. Checked sub menu item

7. Question on VB long sub menu items

8. Global en/dis-abling sub-menu items

9. One set of parameters to be used by multiple sub-reports

10. Handling multiple mouse events in one procedure

11. handling multiple events with one event handler

12. How Would I Get Winsock to to handle Multiple connections on One Port

 

 
Powered by phpBB® Forum Software