Install Delphi Packages Tutorial
There are many free source Delphi components arround the Internet you can install freely and use in your applications. If you need to install a third-party Delphi component, and you only have the.PAS source file(s), follow this step-by-step tutorial and learn how to add the component into an existing package. Note 1: this tutorial covers installing components in Delphi for Win32 (Delphi 7). You'll learn how to install the component. First, start Delphi. A new project is created by default. Close it by pointing to File - Close All.
With the 'Install Component' dialog active, select the file with the component's source (?PAS). Use the Browse button to select the unit, or enter the name of the unit you want to install in the 'Unit File Name' edit box. Note 1: If the unit's folder is in the Search Path, a full path name is not required. If the folder containing the unit file is not in the Search Path, it will be added to the end. Note 2: The 'Search Path' edit box displays the path used by Delphi to search for files.
Leave this as it is. Gajic, Zarko.
'Installing a single source Delphi component into an existing Package.' ThoughtCo, Feb. 22, 2016, thoughtco.com/installing-a-single-source-delphi-component-1058428. Gajic, Zarko. (2016, February 22). Installing a single source Delphi component into an existing Package. Retrieved from Gajic, Zarko.
'Installing a single source Delphi component into an existing Package.' (accessed February 2, 2018).
Writing Delphi Components - Creating and Installing Packages If you want your components to have a design time presence (placed on the toolbar and be able to set parameters via the Object Inspector), then they must be placed in a package and installed in the IDE. Though it is not documented anywhere, you need to know that packages can only be installed in the same version of Delphi that was used to compile them. (The.dcu files are version dependent.) This means that if you share some component. either you release the source code (so it can be installed in any version). or you compile a package in every version of Delphi (including those that are not yet released) Of course, this brings up the question of how to make components available in C Builder. (Maybe I'll figure this out later.) -You'd think this was documented somewhere. (Actually, the help contains a significant amount of information on this.
However, it is very difficult to find and to understand.) (In the help, you can try Installing component packages. However, it does not mention the required resource file. To find this, search the help for installing components, select Compiling components into packages, and click on Installing component packages.) To use a unit in another program, all you need is the.dcu (Delphi Compiled Unit) file. Components are a bit more complicated - they need to be registered so that their icons will be displayed on the toolbar, and they need to execute at design time so that they can paint themselves and make appropriate property assignments. To accomplish this, you will need at least 2 files in addition to the.dcu files - PackageName.bpl, and PackageName.dcp. Zakazana retoryka ebook.
If any of the included units include a resource file (either.res or.dcr), then all those files will also be necessary. (See to generate these.) PackageName.dpk, PackageName.dcu, and the.pas files included in the package do not need to be distributed. (They are used to build the package, they are not needed to use it.) Ext Description Comment pas Pascal source code Do not need to distribute, but required to step through the code during debug dcu Delphi Compiled Unit One for each pas-file. Must distribute if the exe does not call the associated bpl-file (dll-file). ( Project / Options. / Packages / Build with runtime packages is disabled.) There is also a dcu-file associated with the dpk-file.
This one should not be distributed. Bpl Borland package library Run-time dll, must distribute. Also used when Project / Options. / Packages / Build with runtime packages is enabled. Dcp Delphi compiled package Must distribute, used at Design-time, contains Design-time code for all the dcu-files dpk Delphi package Source file that defines the package. Create via File / New.
/New / Package. Pce Package Collection Editor The source file used to define a dpc-file.
Dpc Delphi Package Collection This is a collection of the files needed to install one or more packages. Create this using Tools / Package Collection Editor. Hlp toc cnt Borland Help Contents Menu MS Help Contents Menu Provides context sensitive help for the component When moving a package to another machine, copy PackageName.bpl and PackageName.dcp from Machine1 Delphi5 Projects bpl to the Machine2 Delphi5 Lib. (These are the default directories. I actually use different directories and modify Delphi so that it can find them.
See Tools / Environment Options. / Library.) Also copy the design time resource file PackageName.dcr to the Delphi lib directory. (If you use an.res file, make sure that it does not contain a MAINICON and.) Then Install the package using Component / Install Packages ( Install is also a button in the Package dialog box.) Install includes the component buttons on the component tool palette. Notes:. The.bpl (Borland package library) file resources can be read by the. dclxxx - Design time Component Library, xxx should identify you or your company. Your dclxxx.bpl files reference vcl50.bpl.dcp and.dcu files must be in the Delphi Library Path.
When present, an.dpc (package collection) file contains the other files (dcp, dcu, bpl). Therefore, it is the only file needed. (Note that dpc dcp.). To add your component to an existing package,. Select File / Open. /.dpk.
Add the appropriate source files. Press compile This assumes that you already have a package and the necessary help files.
Install Delphi Packages Tutorial Software
It also assumes that you want to install all the related files in a single directory (not necessarily the best approach) instead of scattering it around like Borland suggests (has some advantages). Under C: Program Files Borland Delphi5, create the directories Packages PackageName. Enter the directory via Tools / Environment options. / Library / Library path I used - $(DELPHI) Packages PackageName. Copy PackageName.bpl and PackageName.dcp to the new directory.
Install the package via Component / Install Packages. Press the Add button. Select your bpl file (the default directory is C: Program Files Borland Delphi5 Projects). At this point, the component(s) will be visible in the tool bar and can be placed on a form.
However, the form won't compile. For each.pas file listed in PackageName.dpk, copy the corresponding.dcu file to the new directory. Copy each.dcr file listed in PackageName.dpk to the new directory. If there are any actions, copy the associated.dfm files to the new directory (these contain the icons). Copy the help files (hlp, toc, cnt) to the new directory and In general, I prefer to build complete exe files that don't use any dll's other than those provided by Windows. However, if Project / Options. / Packages / Build with runtime packages is checked, then the PackageName.bpl file is used (at run time) instead of the.dcu files (at compile time).
Since (at this point) the.bpl file is not in the windows search path, your program will not run until you add it to the path. You can place a copy of the.bpl file in one of these directories Path on my system Extensions C: Program Files Borland Delphi5 Bin bpl, dll C: Program Files Borland Delphi5 Projects Bpl its up to you C: Program Files Borland Delphi5 Projects exe (default output directory) Same directory as your exe exe (custom output directory) or you can modify your system's search path (I don't recommend this). In one test case (just a simple form), the exe file was 15 kb using bpl's, and 356 kb using dcu's. (In another test, just a form and no components, it was 14 kb and 298 kb.) When developing components, be sure to have the.dcu file in the search path Project / Options. / Directories / Search path In order to debug a component (set break points), the.dcu and.pas files should be in the same directory or at least the source file needs to be in the Debug Source Path ( Project / Options. / Directories). In order to step through vcl code, the.dcu files are already in the search path.
Therefore, you only need to include the.pas files in Delphi5 Source Vcl in the Debug Source Path. It appears that there may be a small difference between machines. Today (5-2003), I had to enable the use of Debug DCUs in order to step through the VCL files - Project / Options. / Compiler / Use Debug DCUs - and Delphi5 Source Vcl was NOT in the Debug Source Path. I don't know how I was able to step through the VCL before. To place a component on the toolbar, you need to create a package.
From the Delphi menu, select File / New. / New / Package. In the package window, make sure that Contains is highlighted and click Add.
Include all the applicable.pas files. Including.dcu files (one of the options) seems to have no purpose - it still tries to find the.pas files when it compiles.
Click the Options button. On Description tab - the Description should contain a generic identifier that represents your brand and a phrase the describes the package. If this is omitted, then only the filename and path will be displayed when you look at the list of installed packages. On Version Info tab - CompanyName, FileDescription, FileVersion - Though these are stored in only the.dof and.res files, they should be entered. Save the package via File / Save. It does not matter if you save the package before or after the files are added, either way, the hideous long path names are used.
I really prefer shorter relative path names. (Delphi 6 uses relative names.). Press Compile to produce.dcu files for each.pas file and one for the package itself. It also produces the.bpl and.dcp files. Use Install to add the package to the Windows registry and place the components on the toolbar. The package definition is stored as plain text in dclxxx50.dpk.
You can add additional components by editing and recompiling this file. (By convention, I name package files as dclpackageIDDelphiVersion - dcl - Delphi Compiled Library.) By default, your.bpl and.dcp files are placed in C: Program Files Borland Delphi5 Projects Bpl In general, this is good because it is already in the necessary path definitions.
However, I prefer to keep everything related to a project in a single directory tree. As a result, I suggest that you change Project / Options. / Directories/Conditionals / Unit output directory Project / Options. / Directories/Conditionals / BPL output directory Project / Options. / Directories/Conditionals / DCP output directory to point elsewhere.
Comments are closed.