# Create a Viewing API Window

You must create a new VAPI window for each document that you open; each VAPI window manages only one document at a time.

You can create multiple VAPI windows to handle multiple documents simultaneously. After you create a VAPI window, you can use the Viewing API to manage the document by sending messages to the window and receiving notification messages from the window. When you are finished with the document, you destroy its VAPI window.

To create the VAPI window, use the standard Windows API functions `CreateWindow()` or `CreateWindowEx()`, with the following parameter values:

Parameter | Value/Description
--- | ---
`LPCTSTR lpClassName` | `VAPIDF_VAPI_WINDOW_CLASS_NAME` (defined in `kvvapi.h`).
`LPCTSTR lpWindowName` | `NULL`.
`DWORD dwStyle` | `WS_CHILD` or `WS_DISABLED`
`int x, y` | `0, 0`
`int nWidth` | The width of the application (parent) window.
`int nHeight` | The height of the application (parent) window.
`HWND hWndParent` | The handle of the application window. (See note below.)
`HMENU hMenu` | `NULL`.
`HINSTANCE hInstance` | The handle of the VAPI library.
`LPVOID lpParam` | A pointer to a TPVAPICreateParams structure that specifies optional parameters. Through this structure, you specify whether you are using an initialization file or registry settings.

For example:

    hWndVAPI = CreateWindow (VAPIDF_VAPI_WINDOW_CLASS_NAME,
                        NULL,
                        WS_CHILD | WS_DISABLED,
                        rc.left, rc.top, rc.right, rc.bottom,
                        hWnd,
                        NULL,
                        hLibVAPI,
                        &CreateParams);

## Get the Viewer Window of the Document

The Viewer window is a document-specific window that the VAPI window creates when you open a document. Because the Viewer window is controlled by the VAPI window, normally you should not need the handle of the Viewer window.

The Viewer window is subclassed by the VAPI window. That is, when the VAPI window creates the Viewer window, it subclasses the Viewer window so that the VAPI window intercepts all messages sent to the Viewer window. This allows the VAPI window to control the Viewer window and to handle the right-mouse context menu and common operations such as SaveAs.

Depending on the document type, the Viewer window might also create several child windows in order to handle the document. For example, when you open a spreadsheet document, the VAPI window creates a `[WorkBook]` Viewer window, which in turn creates a `[SpreadSheet]` Viewer window for each spreadsheet page when it is accessed. All VAPI child windows are destroyed when the VAPI window is destroyed.

- To get the Viewer window handle of a document, use the VAPIMWP_INIT_GETHWNDVIEWER message.

- To disable the Viewer user interface for a document (that is, when the Viewer asks if the user interface is disabled before creating a dialog box), respond to the VAPINMWP_INIT_DISABLEUI notification message.

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm