Search code examples
delphic++builderc++builder-2007

Default File Layout in C++ Builder (and Delphi)


I've had a major annoyance with the C++ Builder IDE for some time now. When I code I always use a standard layout for the code files. I have a standard header that I use, including, ie. the License of the file, filename, date, etc.

But I haven't been able to find anywhere to insert this, so that when I - for instance - create a new unit, get this header inserted automatically. Of course I can just paste it in, every time, but it gets a bit irritating to use time doing this.

So my question is - is it possible to create a file template for default C++ files or modify the existing ones so that they always start with my predefined layout. My fear is that just as with most other things in the C++ Builder IDE, this is hardcoded into it.

Currently creating a new unit creates a .cpp file with:

//---------------------------------------------------------------------------


#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

and a corresponding header file with:

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#endif

This is what I wish to alter to my own defined layout.

I'm using Codegear C++ Builder 2007.


Solution

  • See "Adding Items to the Object Repository" in the help file.

    Basically, 1. Create the unit file(s) as you wish 2. Go to Project -> Add to Repository 3. Add information. 4. It will be available from the File -> New... area

    There are also ways to share and edit repository items. The default distribution items are not quite as flexible, but creating your own should do just what you need.