
Adobe Acrobat SDK
Creating Menus and Menu Commands
Developing Plug-ins and Applications
Adding a menu command to an existing menu 91
●
Modifier keys, if any, that are used as part of the shortcut. Must be an OR of the Modifier Keys values,
except that
AV_COMMAND
cannot be specified.
●
An
AVIcon
object that represents the icon to show in the menu command, or
null
if no icon is
shown. In Windows, a valid icon is a 24x24 sample monochrome
HBITMAP
. In Mac OS, an icon is a
handle to a standard SICN resource. For information about creating an
AVIcon
object, see
“Creating toolbar buttons” on page 100
.
●
An
ASExtension
value that registers this menu command. For information about an
ASExtension
value, see the
Acrobat and PDF Library API Reference
.
The
AVMenuItemNew
method returns an
AVMenuItem
object.
AVMenuItem menuItem = AVMenuItemNew ("Show Message", "ADBE:ExternWin",
NULL, true, NO_SHORTCUT, 0, NULL, gExtensionID);
5. Attach the menu command to a menu by invoking the
AVMenuAddMenuItem
method and passing
the following arguments:
●
An
AVMenu
object to which a menu command is attached.
●
An
AVMenuItem
object that is attached.
●
The location in the menu that specifies where the command is added. You can specify
APPEND_MENUITEM
to append the menu command to the end of the menu.
If this method is successful, the menu command is added to the specified menu.
AVMenuAddMenuItem (FileMenu, menuItem, APPEND_MENUITEM);
6. Release the typedef instances to free memory. To release an
AVMenu
instance, invoke the
AVMenuRelease
method and pass the
AVMenu
instance. To release an
AVMenuItem
instance, invoke
the
AVMenuItemRelease
method and pass the
AVMenuItem
instance.
Adding a menu command to an existing menu
The following code example creates a new menu command that displays the text
Show
Message
and
attaches it to the File menu.
Example 6.1
Adding a menu command to an existing menu
//Declare menu variables
AVMenubar Themenubar = NULL;
AVMenu FileMenu = NULL;
AVMenuItem NewMenuCommand = NULL;
//Retrieve the menu bar in Adobe Reader or Acrobat
Themenubar = AVAppGetMenubar();
//Retrieve the File menu
FileMenu = AVMenubarAcquireMenuByName(Themenubar, "File");
//Create a new menu command
NewMenuCommand = AVMenuItemNew("Show Message", "ADBE:ExternWin", NULL, true,
NO_SHORTCUT, 0, NULL, gExtensionID);
if (NewMenuCommand == NULL)