Win32 API names and procedures (MIT/GNU Scheme 10.1.4)

Previous: Windows Foreign Procedures, Up: Foreign function interface [Contents][Index]

#### 18.2.3 Win32 API names and procedures

This section is a moving target.

The `#define` values from `wingdi.h` and `winuser.h` are available as bindings in the `(win32)` package environment. The `#define` symbols are all uppercase; these have been translated to all lowercase Scheme identifiers, thus `WM_LBUTTONUP` is the scheme variable `wm_lbuttonup`. As Scheme is case insensitive, the upper-case version may be used and probably should to make the code look more like conventional Windows code. The Scheme bindings have been produced automagically. Most of the `#define`-symbols contain an underscore so there are not many name clashes. There is one very notable name clash, however: `ERROR` is `#define`d to 0, which shadows the scheme procedure `error` in the root package environment. To signal an error, use `access` to get `error` from the system global environment:

    (declare (usual-integrations))
    …
    ((access error system-global-environment) "Complain" …)

The set of procedures is incomplete because procedures have been added on a by-need basis for the implementation of other parts of the system, e.g. Scheme Graphics. Look in the implementation for further details.

Win32 API procedure names have been uniformly converted into Scheme identifiers as follows:

- A leading uppercase letter is translated into a lowercase letter.
- Subsequent sequences of uppercase letters are translated into lowercase letters preceeded by a hyphen (minus symbol), i.e. hyphens are inserted at a lowercase to uppercase transition.
- Predicates beginning with `Is` finally have a question-mark appended.

Example: applying these rules to `IsWindow` yields `is-window?`, and `GetDC` is translated into `get-dc`.