Embedding preview into host window

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Embedding preview into host window

Postby Brent Rose » Wed Apr 04, 2012 3:33 am

I need some help getting a custom embedded preview window. I can follow the essence of this (I think) described in the DLL Reference under VpeOpenDoc, but do not understand how to interface with the DLL procedures properly (using 32 bit Delphi VCL).

Are there some "external" declarations defined somewhere? Or do I have to LoadLibrary/FreeLibrary and link to them somehow?

In this code (similar to the sample shown in the documentation), FPreviewForm is my windows form (TForm) to be used for the preview, but none of the Vpe procedures used are finding the DLL as it stands.

Code: Select all
var
  AHandle: THandle;
begin
  AHandle := VpeOpenDoc(FPreviewForm.Handle, 'Test', 0);

  VpePreviewDoc(AHandle, 0, VPE_SHOW_MAXIMIZED);

  VpeCloseDoc(AHandle);
end;


What I'm trying to achieve is my own preview form with some customised functions on it that are not available on the default VPE preview form.

Thanks for any assistance you can provide.
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Embedding preview into host window

Postby IDEAL Software Support » Wed Apr 04, 2012 11:34 am

You should definitely NOT use the DLL with Delphi. It is much more comfortable to use the special VPE-VCL component that is shipped with every edition of VPE. Embedding the preview into a form is also a snap then and demonstrated in one of the demo source codes for Delphi, which are provided together with the VCL.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Embedding preview into host window

Postby Brent Rose » Thu Apr 05, 2012 6:25 am

That was easy -thanks! I found the ExternalWindow property...

Having got that far, however, I now cannot discover how to open an existing VPE file. :( Can you offer an example, please.

The documentation offers this advice:

Tip: If you want to preview or print an already created VPE-Document file, DON’T USE
ReadDoc(). Use OpenDoc() with a Swap File instead.


However, OpenDoc does not take a filename parameter...???

I looked at "OpenFileDialog", but I do not want a dialog prompt, just to open the report directly. In any case, it appears that OpenFileDialog only works when some other report is already open (??), and does not return the users response (accept or cancel). I do not understand how this is intended to work.

Sorry if I have overlooked some simple way to do this :?
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Embedding preview into host window

Postby IDEAL Software Support » Thu Apr 05, 2012 8:53 pm

Set the property SwapFileName before calling OpenDoc().
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Embedding preview into host window

Postby Brent Rose » Thu Apr 05, 2012 10:21 pm

Sorry, you misunderstand me. I have set the SwapFileName - no problem there.

I simply want to programatically open an existing report file eg "C:\Temp\MyDoc.vpe" directly into a preview window - not have the user required to manually use an open-dialogue.

I might imagine something obvious like:

Code: Select all
  ReportEngine.OpenDoc('C:\Temp\MyDoc.vpe');


...but, of course, OpenDoc does not take a filename parameter.
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Embedding preview into host window

Postby IDEAL Software Support » Fri Apr 06, 2012 7:26 am

Set SwapFileName = 'C:\Temp\MyDoc.vpe', then call OpenDoc(), and it will open the file. Please read the manuals.
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm

Re: Embedding preview into host window

Postby Brent Rose » Fri Apr 06, 2012 8:23 am

Thank you - I understand now: SwapFileName = ReportFileName.

NB I do actually read the manual, believe it or not - its just that the meaning you intend isn't necessarily the meaning conveyed to someone else. "SwapFile" means something quite different to me... I didn't perceive it to be the "report file name".

Thanks for your patience.
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Embedding preview into host window

Postby IDEAL Software Support » Tue Apr 10, 2012 10:15 am

SwapFileName is the right name, since setting this property instructs VPE to keep only the current page in memory - all other pages are read from / written to disk. To read or write a document, use ReadDoc() and WriteDoc().
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 10 guests

cron