After you have defined a template class, you can create any number of instances of that class.
You can use template class instances to provide different descriptions of a template, search for different default file names, look in different default directories, and so on. Each of these attributes of a template class instance is affected by the document registration table passed to the template class constructor.
Document registration tables let you specify the various attributes and place them in a single object. The object type is TRegList, although in normal circumstances, you should never have to access this object directly. To create a registration table,
- Start your registration table definition with BEGIN_REGISTRATION. This macro takes a single parameter, the name of the registration object. This name can be whatever you want it to be, although it should be somewhat descriptive of the particular template instance you want to create with it.
- Register data items in the table. You can place these items in the table using the REGDATA macro. REGDATA takes two parameters. The first is a key that identifies the type of data, while the second is a string containing the actual data. The key should be a string composed of alphanumeric characters; you don't need to place quotes around this value. The actual data string can be any legal string; you do need to place quotes around this value. Also, you don't need to use commas or semicolons after the macros. There are three data items you need to enter in the table for an instance of a document template:
- The description value is a short text description of the template class indicates the type of data handled by the document class and how that data is displayed by the view class.
- The extension value indicates the default file extension for documents of this type.
- The docfilter value indicates the file name masks that should be applied to documents when searching through file names.
- Register flags describing how this document type is to be opened or created. These document flags can be registered with the REGDOCFLAGS macro. REGDOCFLAGS takes a single parameter, the flags themselves. The flags specified can be one or more of the following:
dtAutoDelete | Close and delete the document object when the last view is closed. |
dtNoAutoView | Do not automatically create a default view. |
dtSingleView | Allow only one view per document. |
dtAutoOpen | Open a document upon creation. |
dtHidden | Hide template from list of user selections. |
- After you have registered the necessary data items and the document mode flags, you can end the table definition with the END_REGISTRATION macro. This macro takes no parameters. You do not need to append a semicolon at the end to the line.
Example
The code below shows a sample registration table declaration. The resulting registration table is called ListReg and applies to a document template class described as a Line List, which has the default extension .PTS and the default file-name mask *.pts, is set to be automatically deleted when the last view on the document is closed, and is hidden from the list of documents available to the user.
#define REGDATA(var, val)
#define BEGIN_REGISTRATION(regname)
See Also