There are also certain capabilities and restrictions that apply to code executing in the application execution context.
- When the execution context your code is running under is not implicit in your code structure, you can make this query to find if it is the application execution context:
virtual bool
AcApDocManager::isApplicationContext() const = 0;
- All ActiveX user input members may be used, but make sure that you are invoking them on the utility object associated with the active and current document. As noted above, document switching will be disabled when user input is obtained in this context. You can obtain the IAcadDocument* instance that corresponds to the current AcApDocument via the call:
acDocManager()->curDocument()->cDoc()->GetIDispatch(
BOOL bAddRef);
- All ObjectARX user input functions may be called, with the current active document being implicitly used. As noted above, document switching will be disabled when user input is obtained in this context.
- Application code executing from the application context can use the following member function to switch either the current and active document, together or individually, as desired.
virtual Acad::ErrorStatus
setCurDocument(
AcApDocument* pDoc,
AcAp::DocLockMode = AcAp::kNone,
bool activate = false) = 0;
- By alternating between prompting for user input and changing or activating the current document, one can prompt for input from multiple documents from a single execution context and a single sequence of code. The drawback is that document switching by the user is disabled when prompting for input, so the code needs to know which document it wants to switch to.
- When the active and current documents differ, be aware that the ActiveX and ObjectARX user input functions will not operate properly. Use the curDocument() and mdiActiveDocument() functions to check the current and active documents.
- If the application leaves with the current document and active document different, the next input event will restore the current document back to the active document.
- When code executing from the application context is prompting for user input using the ActiveX user input functions, automatic interactive document switching is disabled, although current document switching can be performed.