APIDo_​ChangeWindowID

Changes the current (active) window.

    GSErrCode ACAPI_Automate (
        APIDo_ChangeWindowID,
        API_WindowInfo*     windowInfo
    );

 

Parameters

windowInfo
[in] The identification parameters of the requested front window

 

Return Values

NoError
The function has completed with success.
APIERR_BADPARS
windowInfo is nullptr.
APIERR_NOPLAN
There is no any project opened.
APIERR_BADWINDOW
the requested front window is invalid

For other common API errors see the API Errors document.

 

Remarks

This function is used to change the front window of the server application. It performs the same operation as you click the appropriate menu item in the Window menu.

Generally the current window and the window of the current database are the same. However you must be careful; the database dependent functions work on the current database instead of the database of the current window. The interface functions work on the current window always.

Note, that this function changes the current database also.

This function is very useful to access the database of a section/elevation and detail window if the APIDb_ChangeCurrentDatabaseID function has been failed. It occurs when the section or detail window was not opened any time since the actual project has been opened; the database is not available since it is not regenerated. Once the user switch to the section or detail window, the database becomes available.

This function is a non-undoable data structure modifier function. See more details on this topic at Command Overview.

 

Example


API_WindowInfo      windowInfo;
API_DatabaseInfo    origDB, planDB;
API_Element         element;
GS::Array<API_Guid> elemList;
GSErrCode           err;

BNZeroMemory (&planDB, sizeof (API_DatabaseInfo));
planDB.typeID = APIWind_FloorPlanID;

ACAPI_Database (APIDb_GetCurrentDatabaseID, &origDB, nullptr);
ACAPI_Database (APIDb_ChangeCurrentDatabaseID, &planDB, nullptr);

ACAPI_Element_GetElemList (API_CutPlaneID, &elemList);
for (GS::Array<API_Guid>::ConstIterator it = elemList.Enumerate (); it != nullptr; ++it) {
    ACAPI_Database (APIDb_ChangeCurrentDatabaseID, &planDB, nullptr);
    BNZeroMemory (&element, sizeof (API_Element));
    element.header.guid = *it;
    err =  ACAPI_Element_Get (&element);
    if (err == NoError) {
        BNZeroMemory (&windowInfo, sizeof (API_WindowInfo));
        windowInfo.typeID = APIWind_SectionID;
        windowInfo.databaseUnId = element.cutPlane.databaseID;
        err = ACAPI_Automate (APIDo_ChangeWindowID, &windowInfo, nullptr);
    }
}
 

Requirements

Version: API 2.2 or later
Header: APIdefs_Automate.h

 

See Also

API_WindowInfo,
APIDb_ChangeCurrentDatabaseID,
ACAPI_Automate, API Functions