GFA-BASIC 32 IDE Tips & Hacks

IDE Tips & Hacks provide some hints and answers on issues related to the GFA-BASIC 32 IDE.

How does the Save BAK file option work?

I never actually used it, but I was a bit surprised about the elegance of the "Save BAK file" option in the Properties dialog box. I discovered this not by trying it out or through the need for a previous version of my program, but through disassembling (well that's what I do for a living ;-)). What is happening is the following. After loading a .bak version the IDE remembers the name including the .bak extension until the next Save. Then, just before saving, the bak extension is replaced by g32 and the previous g32 of the program is overwritten. Since the "Save BAK file" option is active consider which file should be the .bak file now. Should this be a copy of the overwritten g32 file or should it be the backup file we used for a fresh start? Clearly, the backup; in this case there is no backup created, because it is already there.

How to set the GFA-BASIC serial key

The following registry keys are necessary to obtain a 'registered' GFA-BASIC version. You will probably have to create them manually using the Registry Editor. The global program settings are in the HKEY_LOCAL_MACHINE\SOFTWARE\GFA\Basic key. Here you must create the values as follows (using a small GB32 program)

SaveSetting "\\HKEY_LOCAL_MACHINE\SOFTWARE\GFA\Basic", , "Owner", "MyName"
", , "Company", "MyCompany"
", , "Serial", "12345678901234"

The Serial key can be any string between 12 and 15 characters.

How to use your own toolbar button images
When starting, GFA-BASIC 32 looks in it's directory for a file named GfaWinTb.bmp containing a strip of button images. If it finds it, the file is loaded and the loading of the toolbar images from GFA-BASIC 32 resources is skipped. The bitmap's size is 352x15, and each images is 16 by 15 pixels. The number of colors is 16.

You can view and obtain the bitmap strip from the GFA-BASIC 32 executable resources by running the following piece of code.

  // Get bmp resource from EXE
  OpenW 1 : AutoRedraw = 1
  Local Handle hBmp
  hBmp = LoadImage(GetModuleHandle(Null), $66, IMAGE_BITMAP, _
  Put 0, 0, hBmp
  FreeBmp hBmp
  Do :  Sleep : Until Me Is Nothing

A bitmap with 256 colors is accepted as well. However, it must contain a standard palette and the transparency color should be grey RGB(192,192,192), the same as with the 16 color image. This is a consequence from the LoadImage API function that converts the grey color value to COLOR_BTNFACE.
In the
Editor Extensions section you'll find some code to associate the images from the toolbar strip to the GFA-BASIC 32 IDE menu.

How to anticipate a syntax check error crash
Always save your work before compiling ;-). Whether you perform a syntax check, start a program, or compile it, in all cases GFA-BASIC 32 invokes the same compile-procedure. It simply passes arguments to the compile function indicating what action to perform. Anyway, when your program contains a syntax error GFA-BASIC 32 cannot recover from, compiling could go wrong in all three cases. To anticipate a syntax error crash you could extend your syntax-check functionality by assigning a GLL extension shortcut key in your default editor extension that saves first and then compiles. For instance:

 Sub Gfa_F2   ' GLL key assignment: F2 save & syntax check
    If Gfa_Dirty Then Gfa_Save
    SendMessage Gfa_hWnd, WM_COMMAND, MakeWParam(0x429, 1), 0 'Shift+F5
Remember this when you do a syntax check next time! Save before 'compile'.

How to flatten the buttons in the the Form editor's toolbox
The toolbar with the OCXs do have a flat style option. Click with the right mouse button on an empty spot in the toolbox and select 'Flat Toolbox'. This option can not be changed through the Properties dialogbox.

How to incorporate Win32 API Help (and use F1 topic help)
Download a copy of the Win32 API Help, if you you don't already have one, and extract the win32.hlp and win32.cnt to your GFA-BASIC 32 directory. Open the GFAWIN32.CNT contents file in Notepad, and add the following lines. First insert the next line at line #3, just after the :TITLE clause:

  :index Win32 SDK API=win32.hlp

Then at the end of the file add the following line to include the win32 contents file.

  :include win32.cnt

Now, when you restart GFA-BASIC you have context sensitive help of all (built-in) Win32 APIs.

How to automatically increment the fileversion
You can have GFA-BASIC 32 to increment the fileversion number automatically. To get this to work, the program must include a FileVersion resource block. The only way to add this block to the code is via the Compile dialogbox. After opening the dialogbox a fileversion resource is added when the dialog box is closed without canceling. You, don't have to do anything else. However, the automatically increment feature is only started when the [+] button in the fileversion propertysheet in Compile dialog box is selected. It keeps a depressed state to show it is on. Once the incremention option is selected, the fileversion will be incremented only once a day, not with every save of the program. (Eventually, your program can get 365 versions per year, but only if you work on it every day). From a compiled program the fileversion can be obtained using App.Minor.

How to give the editor a 3D look
The editor window has simple one-pixel border. As this is GUI style is a bit out of date, you might like to change it to a 3D (WS_EX_CLIENTEDGE) look. Put the following in your Gfa_Init sub of your default GLL extension.
 'Give the editor a 3D border
  Dim l As Long
  l = GetWindowLong(Gfa_hWndED, GWL_STYLE)
  l = l And Not WS_BORDER
  l = l And Not WS_MAXIMIZE
  ~SetWindowLong(Gfa_hWndED, GWL_STYLE, l)
  l = GetWindowLong(Gfa_hWndED, GWL_EXSTYLE)
  ~SetWindowLong(Gfa_hWndED, GWL_EXSTYLE, l)
  ~SetWindowPos(Gfa_hWndED, Gfa_hWnd, 0, 0, 0, 0, SWP_FLAGS)

Hide the Debug Output window from the taskbar
The Debug output window is a non-owned window that shows up in the taskbar when it is opened. When you have more than one instance of GFA-BASIC32 running all those open Debug windows might clutter up your taskbar very quickly. By setting the WS_EX_TOOLWINDOW style the window can be hidden from the taskbar:


Style = GetWindowLong(Debug.hWnd, GWL_EXSTYLE)
  ~SetWindowLong(Debug.hWnd, GWL_EXSTYLE, Style Or WS_EX_TOOLWINDOW)
  ~SetWindowPos(Debug.hWnd, 0, 0, 0, 0, 0, SWP_FLAGS)

How to quickly copy a line to the clipboard
Did you know GFA-BASIC32 provides a shortcut to quickly copy a line to clipboard? When there is no selection the current line is taken when you press Ctrl+Insert or Ctrl+C. This provides a very convenient way to duplicate a line and is more elegant than Ctrl+Y + Ctrl+U.

Statusbar mouseclick functions
You can click in the part of the statusbar where GFA-BASIC32 displays the current cursor position (line and column pos). The well-known Goto dialogbox pops up to let you specify a line number to jump to.
By clicking the most right part of the statusbar you can quickly toggle bewteen insertion and overwite mode.
By clicking on the red circle you can start macro recording; all keyboard presses will be recorded until you press the black stop rectangle or the pause button next to it. Macro recording is a bit limited, because it only records keypresses when the source code editor has the focus!