$ACCELERATOR directive
Note: The $ACCELERATOR directive
is valid only in BCX programs which use the GUI statement. The $ACCELERATOR
directive should be placed immediately preceding the GUI statement.
Purpose: The $ACCELERATOR
directive implements keyboard accelerator access to the command set
of a program.
Syntax:
$ACCELERATOR hAccTable
Parameters:
|
Example:
Below, the $ACCELERATOR directive is used
to facilitate the capture of a keypress for menu items.
$ACCELERATORhAccTableGUI"ACCELERATOR",PIXELSCONSTID_Edit=200'Main Menu memberCONSTID_Options=300'Main Menu memberCONSTID_Open=400'File Menu memberCONSTID_Close=500'File Menu memberCONSTID_Save=600'File Menu memberCONSTID_SaveAs=700'File Menu memberCONSTID_Exit=800'File Menu memberGLOBALForm1ASHWNDGLOBALMainMenuASHMENUGLOBALFileMenuASHMENUGLOBALhAccTableASHACCELSUBFormLoadDIMRAWCaption$SETsAccel[]ASACCEL FCONTROLORFVIRTKEY,ASC("O"), ID_Open, FCONTROLORFVIRTKEY,ASC("S"), ID_SaveENDSEThAccTable=CreateAcceleratorTable(sAccel,2)'========================================================================Caption$="ACCELERATOR Demo"'========================================================================Form1=BCX_FORM(Caption$,6*1.75,18*1.71,160*1.80,100*2.20)'========================================================================' Start Building Menus'========================================================================MainMenu=CreateMenu()' CreateMenu returns a MENU HANDLEFileMenu=CreateMenu()' CreateMenu returns a MENU HANDLE'========================================================================' Build the File Menu First'========================================================================AppendMenu(FileMenu,MF_STRING ,ID_Open ,"&Open"+CHR$(9)+"Ctrl + O")AppendMenu(FileMenu,MF_STRING ,ID_Close ,"&Close")AppendMenu(FileMenu,MF_STRING ,ID_Save ,"&Save"+CHR$(9)+"Ctrl + S")AppendMenu(FileMenu,MF_STRING ,ID_SaveAs,"Save &As")AppendMenu(FileMenu,MF_SEPARATOR,0,"")AppendMenu(FileMenu,MF_STRING ,ID_Exit ,"E&xit")'========================================================================' Build the Main Menu Next'========================================================================AppendMenu(MainMenu , MF_STRING , ID_Edit ,"Edit")AppendMenu(MainMenu , MF_STRING , ID_Options ,"Options")'========================================================================' Attach the File menu to the main menu'========================================================================InsertMenu(MainMenu, ID_Edit , MF_POPUP , FileMenu ,"File")'========================================================================SetMenu(Form1,MainMenu)' Activate the menuCENTER(Form1)SHOW(Form1)ENDSUBBEGINEVENTSSELECTCASECBMSG'========================================================================CASEWM_COMMAND'========================================================================SELECTCASECBCTLCASEID_Exit : PostQuitMessage(0)CASEID_Open :MSGBOX"Open"CASEID_Save :MSGBOX"Save"ENDSELECTENDSELECTENDEVENTS