Accessing Viewer

Before looking at the sample application, this chapter looks at the function that gives applications access to Viewer: the MVAPI function.

MVAPI has the following syntax:

extern BOOL FAR PASCAL MVAPI (hwndMain,lpszMvbFile,usCommand,ulData)

The hWnd parameter identifies the window requesting access to Viewer. Applications use this identifier to keep track of which applications have requested access to Viewer.

The lpszMvbFile parameter specifies the name (with optional path) of the Viewer file being accessed.

The usCommand parameter either specifies the type of search the application uses, or tells Viewer that the application no longer requires access. In our sample, usCommand usually has the constant value cmdMacro, indicating that the application wants to execute a Viewer command. However, usCommand can also take any of the following values:

Value Action

cmdContents Displays the Viewer contents topic
cmdFocus Gives Viewer the focus
cmdId Displays a particular Viewer topic identified by a context string
cmdIdPopup Displays a popup window containing a topic identified by a context string
cmdKey Displays a topic associated with a keyword
cmdNewInstance When used in an expression with the binary-OR operator (| ) and any other command
cmdPartialKey Brings up the Index dialog box and selects the keyword closest to a specified string
cmdTerminate Informs the Viewer application that Viewer is no longer needed

The ulData parameter specifies the topic the application requests Viewer to display. The format of ulData depends on the value of usCommand that the application passes in the MVAPI call. The following table describes the format of ulData for each value of usCommand:

usCommand Value ulData Format

cmdContents Ignored; applications should set to 0L
cmdFocus Ignored; applications should set to 0L
cmdId A far pointer to a string containing the context string of the topic to be displayed
cmdIdPopup A far pointer to a string containing the context string of the topic displayed in the popup window
cmdKey A far pointer to a string containing the keyword for which the topic is displayed
cmdMacro A far pointer to a string containing the Viewer command
cmdNewInstance Ignored; this value of usCommand used only with other commands
cmdPartialKey A far pointer to a string used to select a keyword
cmdTerminate Ignored; applications should set to 0L