User Tools

Site Tools


creating_20a_20keyboard_20accelerator_20table_20from_20a_20resource

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

creating_20a_20keyboard_20accelerator_20table_20from_20a_20resource [2018/03/31 13:19]
127.0.0.1 external edit
creating_20a_20keyboard_20accelerator_20table_20from_20a_20resource [2018/04/16 10:48] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Creating a keyboard accelerator table from a resource===== =====Creating a keyboard accelerator table from a resource=====
  
-//by Jon Ripley, August 2007//\\ \\  The normal method of checking for keyboard hot keys is to use [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin5.html#​inkeyminus|INKEY]] with a negative argument:\\ +//by Jon Ripley, August 2007//\\ \\  The normal method of checking for keyboard hot keys is to use [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin5.html#​inkeyminus|INKEY]] with a negative argument: 
 + 
 +<code bb4w> ​
           SYS "​GetForegroundWindow"​ TO hWnd%           SYS "​GetForegroundWindow"​ TO hWnd%
           IF hWnd% = @hwnd% THEN           IF hWnd% = @hwnd% THEN
Line 10: Line 12:
             REM ...             REM ...
           ENDIF           ENDIF
-\\  ​However there may be circumstances where you want to use an accelerator table that has already been designed and its template is contained as a //​resource//​ within a DLL or EXE file. In that case you can create the accelerator table in your program using the resource data. The code example below uses the accelerator table from the resource data for the BB4W IDE (in BBCWIN.EXE or BBCWDEM.EXE):​\\ \\ +</​code>​ 
 + 
 +However there may be circumstances where you want to use an accelerator table that has already been designed and its template is contained as a //​resource//​ within a DLL or EXE file. In that case you can create the accelerator table in your program using the resource data. The code example below uses the accelerator table from the resource data for the BB4W IDE (in BBCWIN.EXE or BBCWDEM.EXE):​ 
 + 
 +<code bb4w>
         REM Acquire handle to BBCWIN.EXE or BBCWDEM.EXE         REM Acquire handle to BBCWIN.EXE or BBCWDEM.EXE
         SYS "​GetModuleHandle",​ 0 TO hmod%         SYS "​GetModuleHandle",​ 0 TO hmod%
Line 69: Line 75:
           PRINT "​click% = ";​click%           PRINT "​click% = ";​click%
         UNTIL FALSE         UNTIL FALSE
-\\  ​Naturally this code will only run within the **BB4W IDE**, because if compiled to an executable file the accelerator table resource data will not be present.\\ \\  To load an accelerator table from a different file (for example a DLL) then replace the call to "​GetModuleHandle"​ with a call to "​LoadLibrary"​ as follows:\\ +</​code>​ 
 + 
 +Naturally this code will only run within the **BB4W IDE**, because if compiled to an executable file the accelerator table resource data will not be present.\\ \\  To load an accelerator table from a different file (for example a DLL) then replace the call to "​GetModuleHandle"​ with a call to "​LoadLibrary"​ as follows: 
 + 
 +<code bb4w>
         SYS "​LoadLibrary",​ "​EXAMPLE.DLL"​ TO hmod%         SYS "​LoadLibrary",​ "​EXAMPLE.DLL"​ TO hmod%
-\\  ​When the program ends all accelerator tables must be destroyed using code similar to the following. Here **hAccel%** is the handle to the accelerator table:\\ +</​code>​ 
 + 
 +When the program ends all accelerator tables must be destroyed using code similar to the following. Here **hAccel%** is the handle to the accelerator table: 
 + 
 +<code bb4w>
         SYS "​DestroyAcceleratorTable",​ hAccel%         SYS "​DestroyAcceleratorTable",​ hAccel%
 +</​code>​
creating_20a_20keyboard_20accelerator_20table_20from_20a_20resource.txt · Last modified: 2018/04/16 10:48 by richardrussell