Supporting User Selection of New Pop-Up Menu Items

When a class defines new actions for its pop-up menu, it must provide for the processing of the actions when the user selects the action. This is done by overriding the following pop-up menu methods:

┌─────────────────────────┬───────────────────────────────────┐
│Method                   │Description                        │
├─────────────────────────┼───────────────────────────────────┤
│wpMenuItemHelpSelected   │Displays the help associated with  │
│                         │class-specific pop-up menu item.   │
├─────────────────────────┼───────────────────────────────────┤
│wpMenuItemSelected       │Processes class-specific pop-up    │
│                         │menu item.                         │
└─────────────────────────┴───────────────────────────────────┘

Using the previous sample code, MyObject supports SubItem_1 by overriding wpMenuItemSelected, as shown in the following sample code:

/********************  Method Override  ********************************/

/* Process input from the extra menu option that we added */
SOM_Scope void SOMLINK MyObject_wpMenuItemSelected
  (MyObject *self, HWND hwndFrame, ULONG MenuID)

{
  .
  .

  /* Which of our menu items was selected?  */
  switch( MenuId )
  {
    case ID_SUBITEM1:
       .
       .
    case ID_SUBITEM2:
       .
       .
    case ID_SUBITEM3:
       .
       .
    case ID_SUBITEM4:
       .
       .
    default:
       parent_wpMenuItemSelected
  }
}

MyObject can support help for new pop-up menu items by overriding wpMenuItemHelpSelected in a similar manner. These help methods are explained in Object Aid: Help Methods.


[Back: Adding Conditional Cascaded Menus to a Pop-Up Menu]
[Next: Sample Code for Pop-Up Menu Methods]