ACCESSORY DEMO FOR GFA BASIC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ by ACE member Malcolm Hardy GFA Basic has an annoying problem concerning the use of accessories. After using an accessory a hole is left on the screen. This problem has not been corrected with version 3.5. One solution to this problem is to disable the accessories altogether or to provide a mechanism of disabling all other menu entries excepting the accessories when they are to be used and then enabling them again after use of the accessory. Neither of these methods are very satisfactory. This is one way of handling the problem. The solution is as follows; 1. Create a window the size of the work area 2. Save the screen 3. Include an 'ON MENU MESSAGE ' menu event handler After an accessory is closed a window update message is sent to the AES. In this case the window will be the area of screen lying below the menu bar ie; the workspace. This redraw of the window will be detected by the 'ON MENU MESSAGE' which can in turn call a subroutine to redraw the screen to remove the hole left by the accessory. A window must be created in order to detect the message event. It is very important that you remember to deallocate the window otherwise the number of available window handles will decrease, affecting any applications which are run afterwards. The following is a listing of the demo GFA program to handle accessories; Please Note; This code is GFA Basic version 3.5 A compiled version is included on this disk. REM ************************************************************** REM * NO ACCESSORY HOLE DEMO - BY MALCOLM HARDY JUNE 1991 * REM ************************************************************** ' ' Set mouse to default DEFMOUSE 0 ' DIM item_menu$(30) item_menu$(0)=" Desk " item_menu$(1)=" Info " item_menu$(2)="----------------" ' The following menu entries must always be included otherwise your ' menu will lock up whenever accessories have been loaded item_menu$(3)=" " ! Reserved for accessory 1 item_menu$(4)=" " ! Reserved for accessory 2 item_menu$(5)=" " ! Reserved for accessory 3 item_menu$(6)=" " ! Reserved for accessory 4 item_menu$(7)=" " ! Reserved for accessory 5 item_menu$(8)=" " ! Reserved for accessory 6 item_menu$(9)="" item_menu$(10)=" File " item_menu$(11)=" Quit " item_menu$(12)="" item_menu$(13)="" MENU item_menu$() ' ' Set up work area window for screen redraws GOSUB create_window ' ' Monitor Menu events ON MENU GOSUB handle_menu ' ' Monitor Window events ON MENU MESSAGE GOSUB window_event ' DO ON MENU LOOP ' PROCEDURE handle_menu MENU OFF item%=MENU(0) ' SELECT item% CASE 1 ' ' Info message ALERT 0,"| No Accessory Hole Demo | By Malcolm Hardy | May 1991 ",1," OK ",a% ' CASE 11 ' ' When Quit is selected close the window and delete the window ' allocation handle for reuse by other applications ' ~WIND_CLOSE(hndle&) !This function closes the work window ~WIND_DELETE(hndle&) !This function frees the window handle !for subsequent use by other !applications ' STOP ENDSELECT ' RETURN ' ' PROCEDURE window_event ' ' If a redraw of a rectangular window is required eg. an accessory ' was selected put back the screen saved on start up ' IF MENU(1)=20 SPUT screen$ ENDIF RETURN ' PROCEDURE create_window ' Get work area size ~WIND_GET(0,4,xwork&,ywork&,wwork&,hwork&) ' ' Fill workarea with a filled rectangle DEFFILL ,2,4 PBOX xwork&-1,ywork&-1,wwork&+xwork&,hwork&+ywork& DEFFILL ,1 ' ' Save screen on setup SGET screen$ ' ' Allocate a new window with dimensions of the work area hndle&=WIND_CREATE(&X0,xwork&,ywork&,wwork&,hwork&) ' ' Open the new window using the window handle obtained above ~WIND_OPEN(hndle&,xwork&,ywork&,wwork&,hwork&) ' RETURN <<<<*>>>><<<<*>>>><<<<*>>>>