Adding and Removing Standard Pop-Up Menu Items

The pop-up menu of a Workplace Shell object consists of a subset of the standard pop-up menu items and any new menu items defined for the object's class or inherited from other ancestors. The WPObject class defines a set of standard pop-up menu items that are inherited by all Workplace Shell objects. The WPDesktop, WPFolder, WPPalette, and WPProgram Workplace Shell classes define standard pop-up menu items for their descendants. Each standard pop-up menu item is associated with a flag, as shown in the following table:

┌────────────────────┬────────────────────┬────────────────────┐
│Class               │Item Flag           │Description         │
├────────────────────┼────────────────────┼────────────────────┤
│WPDesktop           │CTXT_LOCKUP         │Open Lockup now     │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SHUTDOWN       │Open Shut down      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│WPFolder            │CTXT_ARRANGE        │Open Arrange        │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_DETAILS        │Open Details view   │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_FIND           │Open Find dialog    │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_ICON           │Open Icon view      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SELECT         │Open Select         │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SORT           │Open Sort dialog    │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_TREE           │Open Tree view      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│WPObject            │CTXT_ARRANGE        │Open Arrange        │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_CLOSE          │Close               │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_COPY           │Copy                │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_CRANOTHER      │Create another      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_DELETE         │Delete              │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_DETAILS        │Open Details view   │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_HELP           │Help                │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_ICON           │Open Icon view      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_LINK           │Create shadow       │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_LOCKUP         │Open Lockup dialog  │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_MOVE           │Move                │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_NEW            │Create another      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_OPEN           │Open                │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_PALETTE        │Open Palette        │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_PICKUP         │Pick up an object   │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_PRINT          │Print               │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_PROGRAM        │Open program        │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_PUTDOWN        │Put an object down  │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_REFRESH        │Refresh             │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SELECT         │Open Select         │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SETTINGS       │Open Settings       │                    │
│                    │notebook            │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SHADOW         │Create shadow       │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SHUTDOWN       │Open Shut down      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SORT           │Open Sort dialog    │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_SWITCHTO       │Switch to           │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_TREE           │Open Tree view      │                    │
├────────────────────┼────────────────────┼────────────────────┤
│CTXT_WINDOW         │Window              │                    │
├────────────────────┼────────────────────┼────────────────────┤
│WPPalette           │CTXT_PALETTE        │Open palette        │
├────────────────────┼────────────────────┼────────────────────┤
│WPProgram           │CTXT_PROGRAM        │Open program        │
└────────────────────┴────────────────────┴────────────────────┘

Workplace Shell classes can add or delete standard pop-up menu items from their pop-up menu by overriding wpFilterPopupMenu. The wpFilterPopupMenu method returns the flags that represent the standard pop-up menu items for the object. By removing a standard menu item from the pop-up menu, the override to wpFilterPopupMenu masks the flag that corresponds to the item being removed from the flags that represent the standard pop-up menu items inherited from the object's parent. For example, suppose that printing MyObject has no meaning. To remove the Print option from MyObject's pop-up menu, wpFilterPopupMenu is overridden as shown in the following figure:

/************************* Method Overrides ****************************/

/* Filters out any options from the pop-up menu that don't apply */
SOM_Scope ULONG SOMLINK MyObject_wpFilterPopupMenu
   (MyObject *somSelf,ULONG ulFlags, HWND hwndCnr, BOOL32 fMultiSelect)

{
  MyObjectData *somThis = MyObjectGetData(somSelf);
  MyObjectMethodDebug("MyObject","MyObject_wpFilterPopupMenu");

  /* Don't allow anyone to print MyObject  */
  return(parent_wpFilterPopupMenu(somSelf,ulFlags,hwndCnr,fMultiSelect)
                                  & ~CTXT_PRINT);
}

The flags that represent the standard pop-up menu items of MyObject's parent class are returned from the call to parent_wpFilterPopupMenu. To remove the Print option from MyObject's pop-up menu, these flags are joined to the complement of CTXT_PRINT using the AND logical operand. Conversely, if the pop-up menu of MyObject's parent class did not include the Print option, the Print option can be added to MyObject's pop-up menu by joining these flags to CTXT_PRINT using the OR logical operand.

Note: An object's pop-up menu is inherited from its ancestors. To ensure that calls to wpFilterPopupMenu belonging to the object's ancestors do not add the menu item after it is deleted, or remove the menu item after it is added, the parent_wpFilterPopupMenu is called first.