Fabrizio
Fabrizio

Reputation: 8043

How to use templates defined in other package without adding source file to the project?

I've created a package which contains several templates (TFrame descendants). These templates has been added to the palette. In other packages, I'm trying to use these templates but each time I add one of them, a message appear:

The following unit: %s, is needed in your project to create the template. Do you wish to add it?

mrYes:

Source file is added to the project. Furthermore, it causes the following error on compiling:

E2200 Package '%s' already contains unit '%s'


mrNo:

It's ok, but the question is asked each time I place one of my templates. Me and my collegues will use these templates alot of times and I really would like to avoid that message.


Update 1:

Here are steps to observe the described behavior:

  1. Create a package project named Package1.
  2. Add a TFrame descendant named MyTest.
  3. Add TMyTest to palette (Structure window, right click, add to palette).
  4. Set project output directories to .\out
  5. Build the project.
  6. Add \out to library path.
  7. In the same projectgroup, create a package project named Package2.
  8. Add Package1, to "requires" (in Package2.dpk).
  9. Add a form.
  10. Add a TMyTestTemplate to the form.

Update 2:

I'm looking for a solution which works with Delphi 2007 and Delphi XE7.

Upvotes: 1

Views: 105

Answers (1)

Alexander B.
Alexander B.

Reputation: 130

A bit more work but one that should fit your needs:

  • Create Package FooRuntime(Mark RuntimeOnly), add your TMyFrame
  • Create Package FooDesignTime(Mark DesigntimeOnly), requires FooRuntime, Registers your frame
  • Install FooDesignTime
  • Link your other project to FooRuntime

Without the packages the IDE seems to fail to recognize the units.

Upvotes: 1

Related Questions