Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 3: Windows Resources


To create a shortcut, on the right side of the string that makes up a menu caption, type \t
followed by the desired combination.

Practical Learning: Creating Shortcut Keys



  1. In the Resource View, click Category, right-click Parent, and click Properties

  2. In the Caption box, click to right side of Parent, type \tCtrl+R

  3. In the same way, set the shortcut of Child to Ctrl+D

  4. Test the application and return to MSVC


3.5.3 Accelerator Table....................................................................................


An Accelerator Table is a list of items where each item of the table combines an
identifier, a (shortcut) key, and a constant number that specifies the kind of accelerator
key. Each item is a variable of the ACCEL class whose syntax is:

typedef struct tagACCEL {
BYTE fVirt;
WORD key;
WORD cmd;
} ACCEL, *LPACCEL;

Using a variable or variables of type ACCEL, you can create as many items as needed.
Then declare an HACCEL variable. HACCEL is a handle to a ACCEL and is used to
pass the ACCEL table to the program. This would allow the compiler to translate the
items of the accelerator to keys that the program can use.

Just like the other resources, an accelerator table can be created manually in a .rc file but
MSVC simplifies the process by allowing you to "visually" create the table.
Free download pdf