Building a dynamic right-click context menu in excel

  • Thread starter Thread starter Mareen Philip
  • Start date Start date
M

Mareen Philip

I need to build a right-click context menu with the following requirements:
1. It should show up only when my listobject is selected.
2. Depending on the row which is selected in my listobject, some actions
may/may not be possilble. I want to only add commandbarbuttons for possible
actions. ie, I do not want to add all commandbarbuttons and mark some as
disabled, I want to not add the button based on the context
3. On of my commandbarpopups expend into commandbarbuttons that are dynamic
based on the row (ie, at coding time, I do not know how many
commandbarbuttons there will need to be). I'm generating captions & tags on
the fly for this one.
4. For the buttons in (3), the event handlers all point to the same
function, but pass different parameters.

What is the best way to approach this?
Currently, I'm building up the menu on right click, and tearing it down (by
unhooking events and calling commandbarcontrol->Delete() on each item I
added) after I'm done using it, and it's behaving a little flaky (event
handlers getting called multiple times on a single button click)

Thanks in advance.
 
For number 1, you could add your new menu items to the list object right-click shortcut menus...

commandbars 67 "List Range Popup" and
commandbars 68 "List Range Layout Popup"

and not create a brand new popup
--
Jim Cone
Portland, Oregon USA




"Mareen Philip"
<[email protected]>
wrote in message
I need to build a right-click context menu with the following requirements:
1. It should show up only when my listobject is selected.
2. Depending on the row which is selected in my listobject, some actions
may/may not be possilble. I want to only add commandbarbuttons for
possible actions. ie, I do not want to add all commandbarbuttons and
mark some as disabled, I want to not add the button based on the context
3. On of my commandbarpopups expend into commandbarbuttons that are
dynamic based on the row (ie, at coding time, I do not know how many
commandbarbuttons there will need to be). I'm generating captions & tags on
the fly for this one.
4. For the buttons in (3), the event handlers all point to the same
function, but pass different parameters.

What is the best way to approach this?
Currently, I'm building up the menu on right click, and tearing it down (by
unhooking events and calling commandbarcontrol->Delete() on each item I
added) after I'm done using it, and it's behaving a little flaky (event
handlers getting called multiple times on a single button click)

Thanks in advance.
 
Back
Top