[DUG] Delphi 7 to Delphi 2009
John Bird
johnkbird at paradise.net.nz
Fri Feb 20 12:10:38 NZDT 2009
Here are my notes, I found some great instructions on Steve Trefethens blog
about installing components in D2005/D2006/D2007. (He is ex CodeGear)
I have added notes/examples from my own situation, I make a folder under my
source tree called components, and install my component library from there
Once you get the essentials it is real simple, but you need to follow a
couple of instructions ...
[From Steve Trefethen]
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...".
(JKB Open project D:\D2007\Components\JohnComponents1.dpk
Then in the right most window right click folder icon and select Add
then right click component icon and select Install - compiles etc)
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
Tue 10 Feb 2009 0:50:42 Vista D2007 further notes:
-Edit unit to change Register procedure to install into a different tab if
wished.
-Save into Components folder.
-close all
-Open project d2007\Components\JohnComponents1.dpk/bpl (?)
-right click Contains and select Add
-select unit copied into Components
-right click .bpl box icon, and select compile or install (I think both do
the same).
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.
John
More information about the Delphi
mailing list