MDI Terminology

The following section defines some commonly used terms to describe the multiple document interface.

Active Document

The document that has window focus, and receives the next user input event, unless the user is switching to (activating) another document. The active document is always the current document when processing user input, but programs can temporarily change the current document during some operations.

Application

The overall running program and associated objects that are common to all open documents, such as the MFC class CWinApp. There is one and only one application per invocation of an executable program.

Application Context

Short for “application execution context.” See “Execution Context, Application”.

Command

Throughout this section, the term “command” refers to a variety of AutoCAD constructs. A command consists of a program sequence performed as a logical unit of work that can be requested by the user or one of the AutoCAD scripting engines. No matter what construct is used, a command can be undone independently of other actions performed during system operation.

Specifically for the MDI API, a command is a sequence of code that begins by locking a document and ends by unlocking a document. In common cases, this locking and unlocking will be performed by ObjectARX but during other times the application must do the locking and unlocking directly. All of the following AutoCAD constructs are commands:

  • AutoCAD built-in commands.
  • Built-in commands executed directly from the command processor, such as F2 for change screen. This includes function and control keys.
  • AutoLISP function invocations, which can be defined either in AutoLISP or in an ObjectARX application using acedDefun().
  • External program commands defined in acad.pgp.
  • AcEd-registered commands registered from AutoCAD.
  • Actions taken from a modeless dialog window or some other external process, typically hosted by an ObjectARX application.
  • A set of actions taken from an ActiveX application in an external process.
  • Actions taken from VBA through the ActiveX interface.
  • Right-click context menu invocations.
Command, Multi-Document

A set of commands that appears as one command to the user, during which the user can change the current document and a continued logical flow of user prompting is maintained. For example, if an active command is prompting for user input in the current document and the user switches the document, the application cancels the command in the old current document, and queues up a command to commence execution in the new current document.

Command, Nonreentrant

A command that cannot be executed in more than one document at a time. Nonreentrancy can be used for commands that should not be available for more than one document at a time, or when the demands of supporting multiple instantiation are too great to be worth the overhead.

Command Processor

The standard input message polling mechanism in AutoCAD that facilitates combined keyboard and digitizer interaction. A separate command processor exists for each open document. The state of the command processor is maintained as an execution context.

Note: Commands that execute outside the context of a single document, such as modeless dialogs and toolbars posted by AutoCAD or ObjectARX applications, execute from within the application context.
Current Document

Programmatic requests can be made to cause a document's execution context to become active without the user actually perceiving the document as “activated.” This is a transient state only, used primarily by ActiveX and VBA applications.

Database

An AutoCAD drawing, specifically an instance of AcDbDatabase. Although the database is part of a document, it is not synonymous with a document.

Document

A document consists of an MDI document window, an execution context, an associated editor state, and a single current database, plus any number of side databases that are opened in association with it. The current database is the one being displayed and edited via commands. The side databases are either used by xref or for general use. The document also includes system variables that are associated with a given drawing such as the current viewport variable. Documents are uniquely identified by their address, which is the AcApDocument* pointer.

Drawing

Synonymous with database.

Edit Session

Usually synonymous with document, but sometimes includes its entire history since the document was opened, as well as the current state of the session.

Execution Context, Application

The command state that is active when new OS level messages are pending. It is independent from all document execution contexts.

The following types of commands execute from this context:

  • External ActiveX Automation requests (such as Visual Basic)
  • VBA
  • Modeless dialog boxes

These types of commands typically work on the active document, although they are not bound to do so. The intent is to handle document locking and unlocking reasonably transparently for external ActiveX applications and VBA. However, ObjectARX applications posting modeless dialogs will be required to lock and unlock documents explicitly in order to interact with their databases.

MDI-Aware

ObjectARX applications that meet all criteria needed to be successfully executed in an MDI AutoCAD. These criteria are listed in the section MDI-Aware Level. ObjectARX applications can register themselves as MDI aware by calling

acrxDynamicLinker->registerAppMDIAware(pkt);

when receiving the kInitAppMsg within their acrxEntryPoint() function.

Per-Application

A data structure that needs to exist only once per application.

Per-Context

A data structure that needs to be instantiated and maintained for each execution context, including document execution contexts and the application execution context. The AutoCAD command processor is an example of a per-context instantiation.

Per-Document

Any data structure, value, or other item that needs to be instantiated and maintained for each document.

Quiescent

When the command processor in a given edit session has no active

  • AutoCAD commands
  • ObjectARX commands
  • AutoLISP evaluations
  • ActiveX requests
  • AutoCAD menu macros
  • VBA macros

At this point, the Command prompt is being displayed in the command window. Notice that modeless dialogs and toolbars can be posted, as they do not operate through the command processor.

Session

Synonymous with application.

Undo Stack

A repository of state recorded during an edit session, which is used to undo the edit session command by command, when requested. Databases are often associated with an undo stack, which is supplied by the host application. In the case of AutoCAD, databases are typically opened under only one document at a time, because undo stacks correspond to documents.