2.2.4.38.51 Project::Open

Description

Open a new project, or append a project. Current project will be closed and replace with the new one if successful

Syntax

BOOL Open( LPCSTR lpcszFilename = NULL, int nOptions = OPJ_OPEN_NORMAL )

Parameters

lpcszFilename
[input]Origin project name. OPJ extension must be included with full path, if lpcszFilename=NULL, an empty project will be open, so using NULL
has the same effect as creating a new project
nOptions
[input] OPJ_OPEN_NORMAL open a project. Current project is closed, new one is openned.
OPJ_OPEN_READONLY open project as ReadOnly. If lpcszFilename is a ReadOnly file, then project will be open as ReadOnly automatically.
OPJ_OPEN_APPEND append a project to the current project. Use current folder as root to append all contents.
OPJ_OPEN_APPEND_NEW_FOLDER append a project to the current project. Use OPJ filename to create a subfolder in current folder
If current project is readonly, append will fail.

Return

TRUE for success, this method will check file existence before attempting to open, so will immediately return FALSE if file does not exist

Examples

EX1

// For this example to run, make sure that the variable strPathName inside
// the function is initialized to the pathname of an existing project file. 
void    Project_Open_Ex1()    //Open a new project
{
    string        strPathName = "c:\\myproject.opj";
    if (Project.Open(strPathName))
        out_str("Project opening succeeded.");
    else
        out_str("Project opening failed!");
}

void    Project_Open_Ex2() //Append myproject.opj to the current project. Use current folder as root to append all contents.
{
    string        strPathName = "c:\\myproject.opj";
    if (Project.Open(strPathName, OPJ_OPEN_APPEND))
        out_str("Project appending succeeded.");
    else
        out_str("Project appending failed!");
}

//OPJ_OPEN_APPEND_NEW_FOLDER
void    Project_Open_Ex3() //Append myproject.opj to the current project. Use OPJ filename to create a subfolder in current folder
{
    string        strPathName = "c:\\myproject.opj";
    if (Project.Open(strPathName, OPJ_OPEN_APPEND_NEW_FOLDER))
        out_str("Project appending succeeded.");
    else
        out_str("Project appending failed!");
}

Remark

See Also

Project::Save

Header to Include

origin.h