This example creates an accelerator-table handle for an in memory accelerator table consisting of 3 accelerator keys, using US codepage 437.

#define INCL_WINACCELERATORS    /* Window Accelerator Functions */
#define INCL_WININPUT           /* Key constants                */
#define INCL_WINFRAMEMGR        /* Frame control constants      */
#include <os2.h>

ULONG        ulAccelLen      = 0;          /* Accelerator-table length      */
HACCEL       hAccel          = NULLHANDLE; /* Accelerator-table handle      */
PACCELTABLE  pacctAccelTable = NULL;       /* Pointer to Accelerator-tab le */
HAB          hab             = NULLHANDLE; /* Anchor block handle           */

ACCEL   acctable[] = {
         AF_SYSCOMMAND | AF_ALT | AF_VIRTUALKEY,VK_F7,SC_MOVE,
         AF_SYSCOMMAND | AF_ALT | AF_VIRTUALKEY,VK_F8,SC_SIZE,
         AF_SYSCOMMAND | AF_ALT | AF_VIRTUALKEY,VK_F12,SC_CLOSE};

        /* Get memory for the Accelerator-table and initialize it. */

  ulAccelLen = sizeof( acctable ) + sizeof( ACCELTABLE );
  pacctAccelTable = (PACCELTABLE) malloc ( ulAccelLen );

  pacctAccelTable->cAccel = 3;                 /* Number of ACCEL entries */
  pacctAccelTable->codepage = 437;             /* Code page */
  pacctAccelTable->aaccel[0] = acctable[0];    /* ACCEL entries... */
  pacctAccelTable->aaccel[1] = acctable[1];
  pacctAccelTable->aaccel[2] = acctable[2];

  hAccel = WinCreateAccelTable( hab, pacctAccelTable );


[Back] [Next]