Can I have a custom visual component (a slightly modified TSpeedButton) that could be dragged to form and exists across some project only, not requiring to be registered Delphi-wide? I also do not want to emulate button using TFrame. It should not be available to other Delphi projects.
2 Answers
Unfortunately, no. Using the component at design-time requires putting it into a package that is installed into the IDE. However, you can enable/disable installed packages on a per-project basis as needed.

- 555,201
- 31
- 458
- 770
-
Thank you. Enabling and disabling packages isn't a right solution. It seems that I need to put up with the state of things. – Paul Aug 17 '15 at 15:55
You might be able to use what is known as an interposer class. Define your custom component like this:
type
TSpeedButton = class(Buttons.TSpeedButton)
....
end;
Note that the class name is the same as the parent class. That is required to make the technique of interposing work.
Put your customisations into this interposer class. When you come to build your UI in the designer, use TSpeedButton
from the palette. Make sure that the unit which declares your customised component is listed in the uses clause of each form that contains one of the customised components.
At runtime when the form is streamed, your interposed component will be instantiated rather than the original component.
The downside of this is that you cannot arrange for your customisations to be visible at design time. If you need to set properties that are not present in the vanilla component, then they must be done at run time. That is a consequence of your desire not to install anything in the IDE.
If this approach does not meet your needs then you should make a component in the usual fashion, using a design time package. You can arrange that the package is only included in specific projects, if you so wish.

- 601,492
- 42
- 1,072
- 1,490
-
At the moment I can hardly believe that this technique works, but if it is true, the biggest downside is that it changes behaviour of all SpeedButtons and I need to have both classes available. – Paul Aug 17 '15 at 15:59
-
This technique does work and is well known. At least well known here on SO. You could arrange that your custom component only behaved differently if you set a run time property of the component to switch on the different behaviour. But it's not pretty. You might be better playing a straight bat and making a package, rather than trying to fight the system. – David Heffernan Aug 17 '15 at 16:02
-
It seems that assembling a form at runtime is a better solution, giving up visuality, of course. – Paul Aug 17 '15 at 16:07
-
I particularly disagree. The interposing class will save you a lot of work on arranging and configuring other components in your form. Even the speedButton will be able to be positionated and configured, except for the extra configurations. Considering all that, the suggestion of @DavidHeffernan is practical and effective. – AlexSC Aug 17 '15 at 16:32
-
1@Paul Assembling a solution at runtime does not answer your question. I offered you the only thing that exists that meets the requirements in the question. It's up to you what you do with that information. – David Heffernan Aug 17 '15 at 17:47
-
1It seems, you can try to explictly define the parent class in TForm ascendant declaration like: `SpeedButton1: Vcl.Buttons.TSpeedButton; SpeedButton2: Unit1.TSpeedButton;` can't you? – asd-tm Aug 17 '15 at 19:03