How to Install Components in the Delphi IDE


Delphi 7 has a main menu option for Component|Install Component that guides you through the process of getting a component onto the Palette. Unfortunately, that functionality was lost in the IDE’s transformation to the Borland Developer Studio. I won’t go into details but I was not happy to say the least when I learned of this change.

Regardless, your choices of installing components hasn’t changed it’s just you’re no longer guided through the process. I thought it might be useful to walk through a few scenarios using Delphi 2007. There are many ways to accomplish these tasks so don’t consider this your only option.

Creating and installing a new component into a new Package
Here are the steps necessary to create a new component and get it installed onto the palette though refer to the section below on the caveat with the New VCL Component wizard:

  1. Start the IDE
  2. Select File|New|Package
  3. Select File|Save As and give your package the desired name
  4. Select View|Project Manager
  5. Right click the package node and select Options then be sure to fill in the Description for this package as it will be used in the Install Packages dialog
  6. Select Component|New VCL Component… which will display the New VCL Component Wizard (see note below)
  7. Select TButton as the ancestor and click Next
  8. Leave the defaults for Classname etc. and click Next
  9. Select “Add unit to Package1.bdsproj project”
  10. Select View|Project Manager and right click Package1 and select Install

That will get you a new design time package with a new component installed and on your palette. If you have an existing .PAS file that contains a component(s) all you need to do is right click the Contains node under your package and select “Add…”.

Installing an existing component into a new package
The steps here are pretty much the same as above except at step 4 instead of starting the New VCL Component wizard simply open the .PAS file that contains the component(s) and add it to the Contains node of your package.

Installing components into an existing package
In this case, you’ve already created and installed a design time package and you’d like to add a new component.

  1. Select Component|Install Packages (Sure, this may seem a bit odd since the package we want is already installed)
  2. Find the desired package and select it in the Design Packages listbox
  3. Click the Edit button which will prompt you to cancel the dialog and open the package as a project
  4. Select View|Project Manager
  5. Expand the package node and right click the Contains node under the package and select “Add…” and add your existing .PAS file or select Component|New VCL Component and follow the steps above
  6. Right click the package node in the Project Manager and select Compile which will rebuild and reinstall your design time package

Installing existing design time packages
If you have existing component packages and you want to get them on the palette:

  1. Select Component|Install Packages
  2. Click the Add button and multi-select the design time packages you want to install then click Ok. You don’t really have to worry too much if the package you select is design time or runtime as the IDE will let you know if there is an issue installing the package.

The issue with the New VCL Component Wizard
There is one rather major flaw with the New VCL Component Wizard and that’s that it places both design-time and runtime code into a single unit. The runtime code is the code that implements the component itself. The design-time code is the Register procedure with the call to RegisterComponents which should be removed and placed in a different unit which belongs it a design time package. In the first scenario above it would be wise to create a second, design-time only package and split the code as described. Additionally, you should mark your packages explicitly as design-time and runtime using Usage Options from the Project Options dialog.

Mixing design-time and runtime code in a single package is a bad idea and needs to be  avoided. Design-time code isn’t necessary at runtime and typically contains property and/or component editors along with various registration calls which are only meaningful when the package is installed in the IDE.

Let me know if this was helpful and if you’ve been impacted by the removal of Component|Install Component functionality. I’ve already discussed it with Nick Hodges.

[UPDATE: May 9, 2007] Also see Creating Packages from the Delphi wiki.

13 thoughts on “How to Install Components in the Delphi IDE

  1. Steve,
    What step are you stuck on? What error message, if any, are you seeing? Basically, what’s not working? There isn’t enough to go on in your comment for me to offer any further help.

  2. Well, posting here did not seem to work again. Trying again.
    Steve,
    Blog did not post the first time I tried, then I decided I would rather send you a direct email. Can’t seem to do that using "Contact me" button. I get the message I include at the end of this note. I would rather not send you here what I was going to send on the blog. Why the original response to your blog did not work on my first attempt to send the blog message, I do not know.
    Can you send me an email direct as I can not send one to you. 🙁
    Thanks for your reply.
    Server Error in ‘/blog’ Application.
    A potentially dangerous Request.Form value was detected from the client (ctl08$comment="…oday.
    <<Let me know if this…").
    Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.
    Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl08$comment="…oday.
    <<Let me know if this…").
    Source Error:
    [No relevant source lines]
    Source File: c:\WINDOWS\microsoft.net\Framework\v2.0.50727\Temporary ASP.NET Files\blog\1be4009b\76f63391\App_Web_0dy-09ne.6.cs Line: 0
    Stack Trace:
    [HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (ctl08$comment="…oday.
    <<Let me know if this…").]
    System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +3219534
    System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +108
    System.Web.HttpRequest.get_Form() +119
    System.Web.HttpRequest.get_HasForm() +57
    System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +2025185
    System.Web.UI.Page.DeterminePostBackMode() +60
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
    System.Web.UI.Page.ProcessRequest() +86
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49
    ASP.email_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\microsoft.net\Framework\v2.0.50727\Temporary ASP.NET Files\blog\1be4009b\76f63391\App_Web_0dy-09ne.6.cs:0
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

  3. As I’ve harped on for ages I’ve always thought Delphi’s component installation was greatly lacking. This isn’t as noticeable with small components but once you get into the medium sized components it becomes a messy, inconsistent mire of methods. Part of our training process for new hires is just teaching them all the different ways you can install components. The problem is that since Borland didn’t set standards we now have to deal with…
    – Full-blown stand-alone installers. These are great but rare, they offer full installation with IDE detection, package compilation, registration, updating search paths and creating uninstallers. The only downside is that they are harder to integrate into an automated "mega install" for quickly building out dev machines, but I’ll gladly deal with that. Companies like RemObjects, DevExpress and Raize excel here.
    – Attempts at generic installers. The two I know of are from Mustang Software, used for the VirtualTreeView and SilverPoint’s MultiInstaller, which reads an INI and allows installing of multiple products. Both of these are actually very good options, except almost no one uses them and they aren’t frequently maintained. I use MultiInstaller here at work to install 25+ component libraries, everything from Toolbar2000, DIRegEx, our own custom library, PBear’s HTML, Abbrevia, FastMM, AsyncFree, etc. A good option but no one really uses it.
    – Zip file + readme. Tedious and error prone since not everyone has the same instructions, often the readme isn’t updated to take into account the newest folder layout and assumptions about the developers knowledge are often made. I’ve had to explain even to seasoned developers how to do certain things because the readme skipped steps that I’m sure seemed "obvious".
    – The "Non-Installer Installer". This is the worst form of component installer. It’s basically a folder structure that someone dropped inside an InnoSetup or NSIS install. It unpacks files and creates an uninstaller but does *nothing* else. No component registration, no detection of IDE, no library path update. They are horrible because they imply that they are installing something, that something more than an unzip command has been executed. I always end up repackaging these installs as plain zips so as not to lead on other developers. These cause me the most headaches because I get devs saying, "I installed component X but it’s still not working…"
    I would love to see Borland provide a way for component vendors of all sizes from the one-offs to the full blown to create installers that can do all the needed housework like install, compile, register, update, etc. They’d be able to both be run stand-alone as well as chained together for automated installs to quickly install many components. This would also mean that each new release of BDS would come with the requirements needed to properly register components. Something like this may have prevented the third-party component installer issues that Delphi 2007 had, meaning the fact that a lot of third-party vendors submitted their components for inclusion with 2007 *BEFORE* they were told about having to add extra logic for setting registry values to get MSBuild to pick up a new library path.
    Sorry for the rant, this has always been a sore spot for me on an otherwise wonderful product.

  4. It’s clear to me that the success of the Delphi IDE will at least partially ride on the component market. I personally prefer to use components rather than write tremendous amounts of code for common tasks. (Isn’t this what RAD IS?)
    The ability for not only the enterprise dev house, but also the basic hobby user to drop in components easily seems vital.
    Perhaps someone should write the new CEO a nice email about this? He appears to be listening. I understand it’s poor form to write directly to the CEO of a company rather than a project head, but if he’s listening, it’s more than can be said for Codegear in recent times.

  5. Steve,
    Great post,
    For me it is very helpfull, since I am moving more, and more into developing my own components, and your post plus Nick’s tutorial helps a lot.

  6. Good post, thanks.
    Steve,
    How do you think about D programming language? Is there a possible that CodeGear releases a IDE for D?

  7. bigfoot,
    CodeGear is not focused on the D programming language. Since CodeGear is part of a public company and thus revenue is very important I’d say it may not necessarily be a wise choice to dive into a new language that has little to no user base particularly when there are other far more popular choices available but that’s just my opinion.

  8. Shawn,
    I hear you, there is certainly a need to make all of this stuff easier.
    Rick,
    Thanks for the link I didn’t realize that Rudy had replaced this functionality and will check into it.

  9. Steve,
    Thanks for this! I’m not a strong developer with components, and just started delving into Delphi 2007, and trying to install component code from an old Delphi 7 application threw me for loops. I think I lost half my hair! Your help here straightened me out and despite why CodeGear changed this, I’m a happier boy tonight! -Scott

  10. Hi Steve,
    I have followed your procedure for installing a TasBarcode component (*.pas based) into D2007 – this works very well.
    If I try to do the exact same thing in D2010 – all dialogs are totally identical to the D2007 – BUT when I try to compile a project that includes the custom barcode component, the compiler cannot find the barcode.dcu file. This does not happen in D2007 and can be fixed by maually copying the missing dcu files directly into the project folder – but that is really not the way to do it!
    Do you know if there is any reported differences with respect to paths that need to be considered in D2010.
    Thanks for a great and informative blog.
    Best regards
    Leif

  11. Hi Leif,
    Unfortunately, I haven’t touched Delphi in well over two years and haven’t looked at anything beyond D2007. I suggest posting on the Delphi support forums for help on this.
    Good luck!

Comments are closed.