Windows Help Internal Variables

In the hot-spot example earlier in this section, the HelloWorld function used the internal Windows Help variables hwndContext (a handle to the Windows Help context window) and qchPath (a pointer to the Help filename). In general, after you register a DLL function as a Help macro, you can specify Windows Help internal variables as parameters to that function when the function appears in hot spots or macro footnotes.

In this section, you’ll learn about other Windows Help internal variables that you can pass to DLL functions registered as Windows Help macros. This section also examines in detail one variable that controls how the DLL handles Windows Help errors.

List of Variables

You can use any of the following Windows Help internal variables in DLL functions.

Variable Format Spec Description

hwndApp U 32-bit handle to the main Help window. This variable is guaranteed to be valid only while the function is executing.
hwndContext U Handle to the current active window (either the main Help window or a secondary window).
qchPath S Fully qualified path of the currently open Help (.HLP) file.
qError S Long pointer to a structure containing information about the most recent Windows Help error (described later in this section).
lTopicNo U Topic number. This number is relative to the order of topics in the RTF files used to build the Help file.
hfs U Handle to the file system for the currently open Help (.HLP) file.
coForeground U Current foreground color.
coBackground U Current background color.

Error Handling

The qError internal variable points to a structure containing information about the most recent Windows Help error. The error structure is defined as follows:

struct
 {    WORD  fwFlags;
      WORD  wError; 
      char  rgchError[wMACRO_ERROR]; 
 } QME;

fwFlags

The fwFlags field contains flags indicating how Windows Help responds to errors. The following are possible error flags and their values.

Flag Value Description

fwMERR_ABORT 0x0001 Allows the Abort option. This flag is set by default.
fwMERR_CONTINUE 0x0002 Allows the Continue option.
fwMERR_RETRY 0x0004 Allows the Retry option.

wError

The wError field is a number indicating the type of error that occurred. The following are possible error numbers and their values.

Error Number Description

wMERR_NONE 0 No error (initial value)
wMERR_MEMORY 1 Out of memory (local)
wMERR_PARAM 2 Invalid parameter passed
wMERR_FILE 3 Invalid file parameter
wMERR_ERROR 4 General Help macro error
wMERR_MESSAGE 5 Help macro error with message

rgchError

If the wError field is wMERR_MESSAGE, the rgchError field contains the error message that Windows Help displays.