The constructor for TDocManager takes a single parameter that is used to set the mode of the document manager.
You can open the document manager in one of two modes:
- In single-document interface (SDI) mode, you can have only a single document open at any time. If you open a new document while another document is already open, the document manager attempts to close the first document and replace it with the new document.
- In multiple-document interface (MDI) mode, you can have a number of documents and views open at the same time. Each view is contained in its own client window. Furthermore, each document can be a single document type presented by the same view class, a single document presented with different views, or even entirely different document types.
To open the document manager in SDI mode, call the constructor with the dmSDI parameter. To open the document manager in MDI mode, call the constructor with the dmMDI parameter.
There are three other parameters you can also specify:
- dmMenu specifies that the document manager should install its own File menu, which provides the standard document manager File menu and its corresponding commands.
- dmSaveEnabled enables the Save command on the File menu even if the document has not been modified.
- dmNoRevert disables the Revert command on the File menu. Once you have constructed the document manager you cannot change the mode.
Example
The following example shows how to open the document manager in either SDI or MDI mode. It uses command-line arguments to let the user specify whether the document manager should open in SDI or MDI mode.
class TMyApp :
public TApplication {
public:
void InitMainWindow();
};
void TMyApp::InitMainWindow() {
break;
break;
break;
}
SetDocManager(
new TDocManager(
DocMode | dmMenu));
};
If the user starts the application with the -s option, the document manager opens in SDI mode. If the user starts the application with the -m option or with no option at all, the document manager opens in MDI mode.
See Also