
Adobe Acrobat SDK
Working with Documents and Files
Developing Plug-ins and Applications
Displaying a PDF document within a window 81
//Set attributes that belong to the ExternalDocServerCreationDataRec object
memset(&creationData, 0, sizeof(ExternalDocServerCreationDataRec));
creationData.size = sizeof(ExternalDocServerCreationDataRec);
creationData.platformWindow = (ExternalDocWindowData)externHWnd;
creationData.acrobatProc = NULL;
creationData.crossDocLinkWithDestData = (void *)externHWnd;
//Invoke OpenPDFFile to display an open dialog box that
//enables a user to select a PDF file
//Pass the address of the ASFileSys object
pathName = OpenPDFFile(&myFileSys);
//If PathName is valid
if (pathName) {
//Open the file specified in the file system
retVal = ASFileSysOpenFile (myFileSys, pathName, ASFILE_READ,
&gDocInfo.file);
if (retVal ==0) {
//Create a ASText object used to display in the new window
ASText title = ASTextFromScriptText ("PDF Viewer", kASRomanScript);
//Opens and displays a document from a file, using the specified
//parameters to control the window's size, location, and visibility
AVDocOpenFromASFileWithParams (gDocInfo.file, title, ¶ms);
ASTextDestroy(title);
bWindowIsOpen = true;
} else
AVAlertNote("Failed to open document.");
}
}
}
//Define the AVWndProc function
LRESULT CALLBACK AVWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_DESTROY)
memset (&gDocInfo, 0, sizeof(gDocInfo));
return DefWindowProc (hwnd, msg, wParam, lParam);
}
//Define the InitializeWindowHandler function
ASBool InitializeWindowHandler (void)
{
WNDCLASS wndClass ;
//This is the window class used to display the PDF
wndClass.cbClsExtra = 0;
wndClass.hInstance = gHINSTANCE;
wndClass.style = CS_DBLCLKS;
wndClass.hCursor = (HCURSOR)NULL;
wndClass.hbrBackground = (HBRUSH)NULL;
wndClass.lpfnWndProc = AVWndProc;
wndClass.hIcon = (HICON)NULL;