Word API Functions

There are some functions in Word available to WLLs but not to WordBasic. These functions fill special needs of WLLs in Windows and on the Macintosh, as the following topics explain.

General Functions

Note that the following four WordBasic functions can only be called from a WLL.

wdAddCommand

Registers add-in functions in Word. It takes three arguments: the DocID (which is passed by Word to wdAutoOpen), the name of the function to be registered, and a description.

wdPrint

Same as the WordBasic Print statement; it prints a string in the status bar.

wdGetInst

Returns the handle (a long value) of the instance of Word (Windows only).

wdGetHwnd

Returns the handle (a long value) of the Word window (Windows only).

Timer Messages

On the Macintosh, the single function wdSetTimer supplies timer messages from Word for a WLL to use. When a timer message happens, the WLL gets called from Word with cacCallTimer. Here is the syntax:


short wdSetTimer( short DocID, long Timer);

Parameter

Description

DocID

Identifies which WLL the timer message should be sent to

Timer

The number of milliseconds to set the timer for


A WLL can have a single timer set at any time; calling wdSetTimer clears the old timer before setting a new one. Calling with a Timer value of 0 (zero) clears the old timer.

WLL Windows

On the Macintosh, the following group of functions should be used for WLLs that need windows created for them that Word will send messages to.

After a WLL window has been established, events are handled as follows:

wdOpenWindow

This function opens and displays a WLL window, and returns the window pointer in a long to use in the other WLL window functions. Here is the syntax:


long wdOpenWindow( short DocID, short x, short y, short dx, 
    short dy, long lData, short fFloat);

Parameter

Description

DocID

Identifies which WLL to send messages to

x, y, dx, dy

Specifies the position and size of the window in pixels


Parameter

Description

lData

Contains user data

fFloat

If fTrue, uses altDBoxProc for the window type; otherwise, uses documentProc (does not actually cause the window to float or not float)


wdCloseWindow

Closes a CAPI window, and returns a short containing fTrue or fFalse to indicate success or failure. The function takes the window pointer as a long parameter. Here is the syntax:


short wdCloseWindow( long *Window);

wdCaptureKeyDown

Starts mode in which KeyDown messages are sent to the CAPI window, and returns a short containing fTrue or fFalse to indicate success or failure. This function takes the window pointer as a long parameter. Here is the syntax:


short wdCaptureKeyDown( long *Window);

wdReleaseKeyDown

Stops mode in which KeyDown messages are sent to the CAPI window, and returns a short containing fTrue or fFalse to indicate success or failure. This function takes the window pointer as a long parameter. Here is the syntax:


short wdReleaseKeyDown( long *Window);