<< Click to Display Table of Contents >> OpenDoc |
Creates a new document with one initial blank page, reflecting the current state of all Design Time Properties. You always need to open the document before you may access any methods or runtime properties.
method void VPE.OpenDoc( )
Remarks:
In case of an Error, LastError is set.
You may create an unlimited number of pages per document and an unlimited number of documents simultaneously, but both is limited by available memory. How much memory is needed, depends on the number of objects you insert and what type of objects you insert (a bitmap for example needs much more memory than a single line). So we can't give clear guidelines about memory usage. In case of doubt, use a monitoring tool to view how much memory is needed for your specific kind of document(s). For example, one page in the "Speed + Tables" demo needs about 10 KB of memory. This is really low, but 100 pages need about 1 MB of memory. If the memory usage is too high, we recommend to use File Swapping.
A VPE document can exist without showing a preview. But if a preview is shown, the document is closed and removed from memory by default, when the preview is closed by the user or when the parent window is closed. If you set AutoDelete = false, the document is not closed when the preview is closed.
On non-Windows platforms you can call CloseDoc() to remove a document from memory, or destroy the component itself.
To prevent the runtime error of opening a document that is already open, you have two possible options:
1. You check the property "IsOpen":
Private Sub ButtonReport_Click()
If Report.IsOpen Then Exit Sub
Call Report.OpenDoc
Call Report.VpePrint(1, 1, "Hello World!")
Call Report.Preview
End Sub
or,
2. You disable the control (button, menu-entry or whatsoever), which will cause opening the document, until the document is closed:
Private Sub ButtonReport_Click()
ButtonReport.Enabled = False
Call Report.OpenDoc
Call Report.VpePrint(1, 1, "Hello World!")
Call Report.Preview
End Sub
The closing of the document fires the event "DestroyWindow", so we enable the button here again:
Private Sub Report_DestroyWindow()
ButtonReport.Enabled = True
End Sub