How to detect menu cancelled

G

Guest

Hi there,

I wish to distinguish the situation when the user has popped up my context
menu, run up and down the list of items, but then closed the menu without
clicking a selection. In this case, I want to set the state back to the way
it was before the menu was popped up.

Is it possible to detect this situation - ie Select events are fired for
various items, but Click event is never fired for any item.

I'm really looking for a "menu cancel" event, or failing that, a "menu
closed" event that I can hook into.

Any help greatly appreciated...

Robert
 
G

Guest

I wish to distinguish the situation when the user has popped up my context
menu, run up and down the list of items, but then closed the menu without
clicking a selection. In this case, I want to set the state back to the way
it was before the menu was popped up.
Is it possible to detect this situation - ie Select events are fired for
various items, but Click event is never fired for any item.

The way I do context menus is as follows. I set an output variable to
nothing. I create the context menu starting with
Dim cm as new ContextMenu
I add menu items that include my click handler that will update the
aforementioned output variable. I call cm.Show myself - I never set the
ContextMenu property of a form or control. When Show returns, I do a
DoEvents to let the click event fire. Finally, I do cm.Dispose, otherwise
there will be a memory leak (that was a hard won lesson).

When all this is done, the output variable is nothing if there was no click,
or it is whatever the click handler caused if there was a click.
 
G

Guest

Thank you.

Whilst my situation is a little different from yours (Its a context menu
dropping down from a Toolbar) you have given me enough information to enable
me to solve my problem in a similar way.

Thanks again...

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top