Jump to content

WinLoadAccelTable: Difference between revisions

From EDM2
Created page with " This function loads an accelerator table. ==Syntax== WinLoadAccelTable(hab, Resource,idAccelTable); ==Parameters== hab (HAB) - input Anchor-block handle. Resource..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
This function loads an accelerator table.
This function loads an accelerator table.  


==Syntax==
==Syntax==
  WinLoadAccelTable(hab, Resource,idAccelTable);
  WinLoadAccelTable(hab, Resource,idAccelTable)


==Parameters==
==Parameters==
hab (HAB) - input
;hab (HAB) - input:Anchor-block handle.
 
;Resource (HMODULE) - input:Resource identity containing the accelerator table.
    Anchor-block handle.  
: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.
Resource (HMODULE) - input
:It must be greater or equal to 0 and less or equal to 0xFFFF.
 
    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==
==Returns==
;haccelAccel (HACCEL) - returns
;haccelAccel (HACCEL) - returns:Accelerator-table handle.
:Accelerator-table handle.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_RESOURCE_NOT_FOUND (0x100A)
;PMERR_RESOURCE_NOT_FOUND (0x100A):The specified resource identity could not be found.
:The specified resource identity could not be found.


==Remarks==
==Remarks==
This function returns a different value when called twice in succession with the same parameter values.
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.  
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==
==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.
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.
Line 55: Line 42:


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


if (rc == 0)
if (rc == 0)
Line 64: Line 50:
if (hAccel)
if (hAccel)
   ulCopied = WinCopyAccelTable(hAccel, &pacctAccelTable, ulCopyMax);
   ulCopied = WinCopyAccelTable(hAccel, &pacctAccelTable, ulCopyMax);
</pre>
Definition
<pre>
#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);
</pre>
</pre>


Line 89: Line 59:
* [[WinSetAccelTable]]
* [[WinSetAccelTable]]
* [[WinTranslateAccel]]
* [[WinTranslateAccel]]
[[Category:Win]]
[[Category:Win]]

Latest revision as of 07:25, 7 August 2023

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);

Related Functions