10 December 2020

Version 2.58 December 2020 Update

A new version of GFABASIC 32 is available now. It has a better auto complete that comes with a little help box for the listbox elements. In addition, version 2.58 has support for Direct2D, for developing multiple monitor applications, and comes with a new gfawinx library with new commands and functions. James Gaite did a good job by making the English CHM helpfile up-to-date with the latest information.

Auto complete
Version 2.58 improves on auto complete by doing a better job in showing relevant elements and by providing a little help box.

This (optional) help for auto complete displays the syntax and a small description of the GFABASIC 32 commands and functions. The syntax is also copied to the statusbar and remains visible to help in using the correct syntax even after the auto complete listbox has disappeared. The help is also displayed for the program’s procedures and functions, the lg32 procedures and functions, and the declared DLL functions. Their prototypes are both visible in the help box and in the statusbar.
New parsing routines made it possible to display real time help for variables in the auto complete listbox. The help box shows whether the constant or variable is local or global and constants display their current value. While most of information is obtained while editing, the only structure that needs compiling is a type (UDT) definition. The Type name and members need to present in the internal GB database before auto complete can show its members.

Ditect2D support
Windows’ Direct2D, which is implemented as COM objects, are encapsulated in GFA-BASIC as GB32 - like commands. All the Direct2D command names start with D2, like D2Color, D2Line, D2Brush, etc. To use Direct2D include the GFA-BASIC 32 library direct2d.lg32 in your program. The library is located in the Include directory and exports GFA-BASIC like commands and functions that correspond to the set of graphic commands GFA-BASIC already offers. For instance, the syntax of D2Line mimics the behavior of the Line command, D2DefFill selects a new fill brush as DefFill does, etc.
The new English CHM helpfile plays an important role in developing Direct2D applications.

The new help provides an introduction to Direct2D programming and discusses the D2 command's. The example code presented in the help-topics are stored in the Samples/Direct2D directory. You are encouraged to step through the samples, but you should start reading with the D2GetRT topic in the help-file. D2GetRT is the base in each program to initialize Direct2D and to provide a render target (canvas) to draw on. So, it is a good place to start reading.

DPI-aware applications
To develop DPI-aware apps you'll need two monitors, one regular 96 dots-per-inch display to run the GFABASIC 32 IDE and one high-resolution display to run and test the program. In addition, the manifest of GfaWin32.exe must include the <dpiawareness> tag. For this purpose the Bin directory contains a separate dpi-manifest file that needs to be renamed to GfaWin32.exe.manifest. You can accomplish this by saving or renaming the current manifest (GfaWin32.exe.manifest) and then rename the GfaWin32.exe.dpiawaremanifest to GfaWin32.exe.manifest. See the help-file for more information on creating DPI-aware applications. It provides information for new gfawinx DPI-scaling commands that will help developing high-resolution apps, like ScaleToDpi, ScaleToDpiSng, ScaleXYWHToDpi, and WinDpi, but also LoadFormPos and SaveFormPos to handle loading and saving the application’s main form on multiple monitors.

The Large Address Aware command
When the $LargeAddressAware compiler directive is used in the code, the compiled EXE is modified to handle memory addresses above 2 GB, theoretically allowing access to up to 4 GB of virtual memory. Normally, a 32-bit application can address only the first 2 GB of memory, however on 64-bit operating systems and when the application is large address aware it can access the additional 2 GB memory that isn’t used by the OS.

The gfawinx library
The gfawinx library is the source for new GB32 commands and functions. To stress the importance of these additions they have the same syntax-color in the editor as regular GB32 commands. When a new program is started, the first thing to do is to import this library as follows:

$Library "gfawinx"

Besides the string functions, gfawinx contains several commands to support developing multiple monitor programs. A brief overview of the new commands and functions:

HexDump A debugging aid to show the contents of a piece of memory.
ErrStr Converts the information from the Err object in a single string.
Wide, Ansi Allows conversion between UNICODE and ANSI formatted strings.
Replace Replaces a string in a given string.
StrToArr Separates a delimited – any delimiter character - string into a string array.
Assoc Retrieves a file association-related string from the registry.
GetWorkArea Retrieves the work area of the monitor containing the largest area of a given window.
GetClientSize Retrieves the width and height (in pixels) of any window's client area.
ModifyStyle, ModifyExStyle Modifies the style or extended-style of a window.
SaveFormPos, LoadFormPos Saves and loads the form's position on the screen to and from the registry. Especially useful with multiple-monitor systems.
ScaleToDpi, ScaleToDpiSng Converts pixels based on a 96 dot-per-inch resolution to DPI physical pixels of the Form's display.
ScaleXYWHToDpi Scales ScaleLeft, ScaleTop, ScaleWidth, and ScaleHeight to a form's DPI.
WinDpi Returns the dots per inch (dpi) value of the display for the specified form.
GetProcAddr Returns the address of an exported function or variable from the specified dynamic-link library (DLL).
WinVer Retrieves version information about the currently running operating system (preferred way to obtain Windows’ version).
TimerQ Creates a high-resolution timer wrapped in a (minimal) COM object.

The Include directory
The Include directory contains Windows API library files ready to import in your program using the $Library command. Several include files are modified to export their Declares explicitly by their name. This was necessary because a bug in GB causes a corruption of the Declare-database if the program declared DLL-functions as well.
Their is also a winmacros.inc.lg32 file with commonly used Windows API macros. The include file provides optimized GB functions to mimic the macros from C/C++ header files.

You can download the new update here.