Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>setaccelerator()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
SetAccelerator()
Use an accelerator table
------------------------------------------------------------------------------

Syntax
SetAccelerator( <hAccel> | <aAccel> )   -->   nil

Arguments
<hAccel> is the handle of an accelerator table.

<aAccel> is an array holding a dynamically-defined accelerator
table.  (Produced by the #commands in ACCEL.CH, which use the
name AccelKeyList.)

Returns
NIL.

Description
This function starts using an accelerator table previously
fetched from a resource file, or defined dynamically (using
the ACCELERATORS, AKEY, etc. commands).

Whenever the user uses one of the defined accelerator
keystrokes, an EVENT_ACCELKEY occurs, and can be handled in
any way you wish.  The second example below sometimes calls a
particular function, and other times runs a menu item's code
block.

There is no function to destroy an accelerator table; Windows
frees them automatically.

Example
hAccel = LoadAccelerators( hInst, "myaccel" )
SetAccelerator( hAccel )

Example
#include "accel.ch"
local AccelKeyList

ACCELERATORS

AKEY "b",      ID_SPECIAL, ALT          // Alt-b
AKEY "^B",          ID_CTRLB            // Control-B
AKEY VK_F1,    ID_HELP,    VIRTKEY      // F1

USE ACCELERATORS         // This uses SetAccelerator()

END ACCELERATORS
// . . .

// then, as part of your event handling:
do case
case nEvent == EVENT_ACCELKEY
     DoAccelerate( _LastwParam() )
// . . .
endcase
// . . .


static procedure DoAccelerate( nId )
do case
case nId == ID_HELP
     DoHelp()
case nId == ID_SPECIAL
     // run the code block corresponding to the menu item
     eval( GetMenuBlock( hMenu, "special" ) )
case nId == ID_CTRLB
     eval( GetMenuBlock( hMenu, "another" ) )
endcase
return


See Also: ACCELERATORS AKEY LoadAccelerators()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson