Previous topic

DocCopyPage

Next topic

DocDestroy

This Page

DocCreateΒΆ

DocCreate creates a new document or opens an existing document. The document can contain pages with diagrams. The document will be displayed in a window.

hDoc = DocCreate()
hDoc = DocCreate(ssFileName)
hDoc = DocCreate(ssFileName, nFlags)
hDoc = DocCreate(ssFileName, nFlags, ssPassword)

Return Value

If the function succeeds, the return value is the handle of the newly created document. If the function fails, the return value is 0.

Parameters

ssFileName

ssFileName is the complete filename of an existing IPW or IPZ document or an empty string (“”). If the function is called without parameters or if ssFileName is an empty string a new document will be created. The document will be visible when the fist page is added to the document. It will stay invisible if DOC_HIDDEN is set.

nFlags

nFlags

Value Meaning
DOC_HIDDEN (1) Not visible.
DOC_READONLY (2) Document will be opened read-only.
DOC_NO_AUTOSAVE (128)  
ssPassword

If the document is password protected the password must be specified.

Comment

If the function is invoked without parameters a new document will be created. The document will be displayed as soon as a new page page is added to the document (see DocAddPage).

Example

ssFile = GetRootDirectory() + "/template/tpl_ger.ipw";
hDocTemplate = DocCreate(ssFile, DOC_HIDDEN | DOC_READONLY);
if (hDocTemplate == 0) {
    MessageBoxError("Cannot open template %s", ssFile);
    return FALSE;
}
hDocNew = DocCreate();
DocCopyPage(hDocTemplate, 3, hDocNew);
DocDestroy(hDocTemplate);

Example 2

Creates a new Document from a template, that contains all template pages.

def DocCreateNew(ssTemplate)
{
         hDocTemplate = DocCreate(ssTemplate, DOC_HIDDEN | DOC_READONLY);
         if (hDocTemplate == 0) {
           log_error("", "DocCreateNew", "Cannot open template %s", ssTemplate);
               return 0;
     }
     hDoc = DocCreate();
     nPages = DocGetPageCount(hDocTemplate);
     for (i in 1:nPages) {
         hPageT = DocGetPageHandle(hDocTemplate, i);
         hPage = DocCopyPage(hDocTemplate, i, hDoc);
         PageSetTitle(hPage, PageGetTitle(hPageT));
     }
     DocDestroy(hDocTemplate);
     DocSelectPage(hDoc, 1, FALSE)
     return hDoc;
 }
 // Example call
 hDoc = DocCreateNew("d:/test.ipw")

History

Version Description
R2012 (5.40) New flag DOC_NO_AUTOSAVE for ipz documents.
5.30.2 Flags DOC_SEC_512 and DOC_SEC_4096 removed. New files have always 4096 Bytes/Sector.

id-107438