Because a document must be opened before it can be viewed, printed, saved, or can have any other operation performed on it, viewing a document in the Viewing API means to open and view a document. It is possible, however, to open a document without viewing it, or in other words, to open a document with view mode disabled. In this mode, you can print or save the document without viewing it.
To open a document
Create a TPVAPIOpenDocumentInfo structure.
To open a document without viewing it (view mode disabled), set the VAPIDF_FLAGS_OPEN_WITHOUT_VIEW
flag in the nFlags
member of the TPVAPIOpenDocumentInfo
structure.
Send VAPI a VAPIM_INIT
message with the wParam
set to VAPIMWP_INIT_OPEN_DOCUMENT
, and the lParam
set to the address of the TPVAPIOpenDocumentInfo
structure. See VAPIMWP_INIT_OPEN_DOCUMENT.
For example:
memset (&OpenDocInfo, 0, sizeof(TPVAPIOpenDocumentInfo)); OpenDocInfo.lpszFilePath = szFileName; lResult = SendMessage (hWndVAPI, VAPIM_INIT, VAPIMWP_INIT_OPEN_DOCUMENT, (LPARAM)OpenDocInfo);
To receive the status of the open document expressed as the percent done, wait for the VAPINMWP_INIT_OPENDOCDONE notification message.
To receive the current page number of the document, wait for the VAPINMWP_INIT_PAGENUMBER notification message.
To receive the name of the current object of the document, wait for the VAPINMWP_MULTIOBJ_OBJNAME notification message.
|