次の方法で共有


Associating a Menu Item with an Accelerator Key

OverviewHow Do I

Many times, you want a menu item and a keyboard combination to issue the same program command. You do this by using the to assign the same resource identifier to the menu item and to an entry in your application’s accelerator table. You then edit the menu item’s caption to show the name of the accelerator key.

To associate a menu item with an accelerator key

  1. In the menu editor, select the menu item you want. From the View menu, choose Properties or double-click the item.

  2. In the Caption box, add the name of the accelerator key to the menu caption:

    • Following the menu caption, type the escape sequence for a tab (\t), so that all the menu’s accelerator keys are left-aligned.

    • Type the name of the modifier key (CTRL, ALT, or SHIFT) followed by a plus sign (+) and the name, letter, or symbol of the additional key.

    For example, to assign CTRL+O to the Open command on the File menu, you modify the menu item’s caption so that it looks like this:

    Open\tCtrl+O
    

    The menu item in the Menu editor is updated to reflect the new caption as you type it.

  3. Create the accelerator-table entry in the accelerator editor and assign it the same identifier as the menu item. Use a key combination that you think will be easy to remember.

See Also   , , , , ,