Adding New Application Templates

Adding a new template to Delphi's Object Repository is as simple as using an existing template to build an application. When you have a working application you want to use as a starting point for further development of two or more similar programs, you can save the current status to a template, ready to use later on.

Although Borland calls everything you can put in the Object Repository an object, from an object-oriented perspective this is far from true. For this reason I call the schemes you can save to disk for later use templates. Application templates, in particular, do not relate to objects or classes in any way, but are copied to the directory of your new project. Object Repository sounds much better than Browse Gallery (the name used in Delphi 1), but besides the capability to activate form inheritance, there is not much object-oriented in this tool.

You can add a project to the Repository by using the Project | Add to Repository command, or by using the corresponding item of the local menu of the Project Manager window. As a very simple example, just to demonstrate the process, the following steps describe how you can save the slightly modified version of the default SDI template (shown earlier) as a template:

  1. Open the modified SdiTemp example (or any other project you are working on).
  2. Select the Project | Add to Repository menu command (or the Add Project to Repository command in the local menu of the Project Manager window).
  3. In the Add to Repository dialog box, enter a title, a description for the new project template, and the name of the author. You can also choose an icon to indicate the new template or accept the default image. Finally, choose the page of the Repository where you wish to add the project.
  4. : Click on OK, and the new template is added to the Delphi Object Repository.

Now, each time you open the Object Repository, it will include your custom template. If you later discover that the template is not useful any more, you can remove it. You can also use a project template to make a copy of an existing project so that you can continue to work on it after saving the original version.

However, there is a simpler way to accomplish this: copy the source files to a new directory and open the new project. If you do copy the source files, do not copy the DSK file, which indicates the position of the Windows on the screen. The DSK file holds a list of files open in the editor, using an absolute path. This means that as soon as you open the new project and start working on it, you may well end up editing the source code files of the original project and compiling the files of the new version (the project manager stores relative paths).

This will certainly surprise you when the changes you make in code or in forms seem to have no effect. Simply deleting the DSK file, or not copying it in the first place, avoids this problem.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment