WinLoadAccelTable
This function loads an accelerator table.
Syntax
WinLoadAccelTable(hab, Resource,idAccelTable);
Parameters
hab (HAB) - input
Anchor-block handle.
Resource (HMODULE) - input
Resource identity containing the accelerator table.
Module handle returned by the DosLoadModule or DosQueryModuleHandle functions referencing a dynamic link library containing the resource or NULLHANDLE for the application's module.
idAccelTable (ULONG) - input
Accelerator-table identifier, within the resource file.
It must be greater or equal to 0 and less or equal to 0xFFFF.
Returns
- haccelAccel (HACCEL) - returns
- Accelerator-table handle.
Errors
Possible returns from WinGetLastError
- PMERR_RESOURCE_NOT_FOUND (0x100A)
- The specified resource identity could not be found.
Remarks
This function returns a different value when called twice in succession with the same parameter values.
The accelerator table is owned by the process from which this function is issued. It cannot be accessed directly from any other process. If it still exists when the process terminates, it is automatically deleted by the system.
Example Code
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);
Definition
#define INCL_WINACCELERATORS /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HAB hab; /* Anchor-block handle. */ HMODULE Resource; /* Resource identity containing the accelerator table. */ ULONG idAccelTable; /* Accelerator-table identifier, within the resource file. */ HACCEL haccelAccel; /* Accelerator-table handle. */ haccelAccel = WinLoadAccelTable(hab, Resource, idAccelTable);