ADDACCELERATOR

Top  Previous  Next

Syntax

ADDACCELERATOR(win as WINDOW,fVirt as CHAR,key as WORD,cmd as WORD)

Description

Adds an accelerator (shortcut key) to the window or dialog.

Parameters

win - Window or Dialog to add the accelerator to.

fVirt - Flag indicating which combination of keys activates the accelerator.

key - ASCII or virtual key code.

cmd - ID of menu associated with the accelerator.

Return value

None

Remarks

fVirt can be an or'ed combination of:

@FCONTROL - CTRL key must be held down with the specified key.

@FALT - ALT key must be held down with the specified key.

@FSHIFT - SHIFT key must be held down with the specified key.

@FNOINVERT - Specifies that no top-level menu item is highlighted when the accelerator is used. If this flag is not specified, a top-level menu item will be highlighted, if possible, when the accelerator is used.

@FVIRTKEY - key specifies a virtual key code.  If this flag is not used then key specifies an ASCII key code.  Virtual key codes are listed in the appendix of this users guide.

Example usage

BEGINMENU win
    MENUTITLE "&File"
    MENUITEM "&Load File\tCtrl+L",0,1
    MENUITEM "&Save\tCtrl+S",0,2
    MENUITEM "&Print\tAlt+P",0,4
    MENUITEM "&Quit\tCtrl+C",0,3
    MENUTITLE "&Options"
    MENUITEM "Change Font\tF4",0,5
ENDMENU
 
'add our keyboard accelerators
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("L"),1
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("S"),2
ADDACCELERATOR win,@FCONTROL|@FVIRTKEY,ASC("C"),3
ADDACCELERATOR win,@FALT|@FVIRTKEY,ASC("P"),4
ADDACCELERATOR win,@FVIRTKEY,0x73,5:'F4 key changes font