1
votes

So far, to make things easy, I have always created components that are Desingtime and Runtime and I've used the component wizard. It works fine but I see that separating runtime and designtime is better.

enter image description here

The Frazioni.bpl is a Runtine only package and it has in Contains a pas file called uFraction.pas. It is an utility for fractions and it has inside a class like this:

type
 TFraction = class(TComponent)
 end;

dclFrazioni instead is Designtime only. I am reading More Coding in Delphi and nick says:

First thing to do for a design-time package is to set its Requires clause

Ok but how do I do this? I understand that I have to link the runtime and the Designtime but how? I have built the Frazioni.bpl but when I right click dclFrazioni I have to add a reference but I don't know how.

The designtime only package is just going to have the Register procedure. So basically:

  • Frazioni.bpl = runtime with one (or more) pas file containing the classes I need, they inherit from TComponent.
  • dclFrazioni.bpl = designtime with a pas file containing the Register procedure

I am lost because I don't know how to link them.

2
This should not be a component that you drop onto a design surface.David Heffernan
You need separate runtime and designtime packages only when you have actual designtime-only code, such as component/property editors, IDE addons, etc. It is perfectly fine to have a single runtime+designtime package if it does not contain any designtime-only code in it (and simply calling RegisterComponents() doesn't count, as it is implemented in a runtime package).Remy Lebeau
You could simply compile and build the runtime, right click the dcl, click "Add Reference" and then go to "C:\Users\Public\Documents\RAD Studio\xx.x\Dcp".Alberto Miola

2 Answers

5
votes

You can link your designtime package to your runtime package by adding the name of the runtime package to the requires section of the designtime package's project file.

You can do that by following these steps:

  1. Right click on dclFrazioni.bpl
  2. Click View Source from the Project Manager window.
  3. Add Frazioni (Which is your runtime package) to the requires section.

The resulting file should looks like the following:

package dclFrazioni;

{$R *.res}
....
{$IMPLICITBUILD OFF}

requires
  rtl,
  vcl,
  Frazioni;

contains
  (units...);

end.
3
votes

In your screenshot it lists the tree view item called Requires for your design package. IIRC you can right click that and choose Add Reference. Then select your run-time package.