Re: Runtime-determined ShortcutMenus, best course of action

Re: Runtime-determined ShortcutMenus, best course of action

am 18.12.2007 23:46:26 von Stuart McCall

"JohnH" wrote in message
news:9261cd79-8740-4074-ba09-838061ccb51e@s8g2000prg.googleg roups.com...
> My Customers/Sales/Contacts management database interface is modeled
> as if Customers are objects, Sales are objects owned by Customer
> objects, etc. (I'm running Access 11)
>
> I have Listviews located just about everywhere for the purpose of
> finding/acting on these objects.
>
> I want to design a coherent model to handle contextual popup (shortcut
> menus) for the different kinds of objects that will be clicked on.
> Each object will (naturally) have different methods that apply
> (Customers: Print mailing envelope, Sales: View PO, etc). These
> objects and their methods are mapped in a few "meta-tables" in my
> BE.
>
> I should note, these object-specific menu-items will coinhabit the
> Shortcut Menu with a few global menu items (Open, Delete, etc).
>
> So far, after reading around on MSDN, it looks like I have two general
> options (although I could be missing something):
>
> 1) Create the toolbars manually in design-mode, as Shortcut menus,
> mirroring the data I have in the BE. Then, before I show the popup at
> runtime, copy the object-centric shortcutmenu onto the "Global menu."
>
> 2) Mash up each toolbar at runtime, creating each menu item by reading
> the relevant data from the BE tables.
>
> Does anyone have experience with the kind of thing? What would you
> do?
>
> Also, when you create a command bar (or copy items onto one), what is
> its scope? Does it persist absolutely, per session, per sub-routine?
>
> Any pointers are appreciated.

When you say Listview, do you mean the Activex listview control? I ask
because if you mean an Access listbox then you can create the menu at design
time and set the listbox's Shortcut menu bar property to the name of your
menu.

If (as I suspect) you do mean a Listview control, I'd probably go with your
option 2, because in my experience, the menus can be built quite quickly in
code.

As to your 2nd question re persistence, commandbars can be made to have
cross-session persistence, ie they can survive a database restart. When you
use the CommandBars.Add method, set the 'Temporary' parameter to False.