This example loads an accelerator-table, using the application defined accelerator id, from a resource using the resource handle returned by DosLoadModule or DosQueryModuleHandle. The returned table handle is then used by WinCopyAccelTable to copy the table into an in-memory accelerator table structure.

#define INCL_WINACCELERATORS    /* Window Accelerator Functions */
#define INCL_DOSMODULEMGR       /* Module Manager Functions     */
#include <os2.h>
#define ACCEL_ID 1

ULONG   ulCopied;       /* bytes copied                         */
HACCEL  hAccel;         /* Accelerator-table handle             */
ACCELTABLE  pacctAccelTable;/* Accelerator-table data area      */
ULONG   ulCopyMax;      /* Maximum data area size               */
ULONG   idAccelTable=ACCEL_ID;/* Accelerator-table identifier   */
HAB     hab;            /* anchor-block handle                  */
HMODULE hmodDLL;        /* resource module                      */
CHAR    LoadError[100]; /* object name buffer for DosLoad       */
ULONG   rc;             /* return code                          */

/* obtain resource handle */
rc = DosLoadModule(LoadError, sizeof(LoadError), "RES.DLL",
                   &hmodDLL);

if (rc == 0)
   hAccel = WinLoadAccelTable(hab, hmodDLL, idAccelTable);

ulCopyMax = sizeof(pacctAccelTable);
if (hAccel)
   ulCopied = WinCopyAccelTable(hAccel, &pacctAccelTable,
                                ulCopyMax);


[Back] [Next]