Project's own components

Posted on 2004-10-23
Last Modified: 2010-04-05

I have a project, say in directory MyProj. It uses some components, designed specifically for it. The source code for them is in dir MyProj/MyComponents.
How can I use these components in a project without adding them as a package to the system wide package list that delphi loads whenever it starts?

If i create a package for them and try to add it only to the project in project options window it is stll added to the global package list.
If i dont create package and only add directory "MyComponents" to the project's search path, delphi cannot load the form containing these components.
However in a latter case if i click ignore i can succesfully compile and run the project, the components of course are not beeing initizalized and AV occurs :(

Any ideas?
I'm using Delphi 6, although i could accept solution that works with some other version.

Question by:x-pander
    LVL 12

    Expert Comment

    If you don't want to install the components, the only way to use them into the project is dynamically creation i.e.:
    (Include into the uses clause Units containing the source code for them)

    unit Unit1;


      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Buttons, SmallCalendar, ExtCtrls, ExExPanel;

      TForm1 = class(TForm)
        Button1: TSpeedButton;
        Button2: TSpeedButton;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        { Private declarations }
          ExExPanel1: TExExPanel;
          eCalendar1: TeCalendar;
        { Public declarations }

      Form1: TForm1;


    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
      ExExPanel1 := TExExPanel.Create(Self);
      ExExPanel1.Parent := Self;
      ExExPanel1.Top := 16;
      ExExPanel1.Left := 8;
      eCalendar1 := TeCalendar.Create(Self);
      eCalendar1.Parent := Self;
      eCalendar1.Top := 16;
      eCalendar1.Left := 128;

    procedure TForm1.FormDestroy(Sender: TObject);

    LVL 12

    Accepted Solution

    First: declare the components into the public section of the TForm

          ExExPanel1: TExExPanel;
          eCalendar1: TeCalendar;

    Second: create dynamically the components, set the Parent, Top, Left .... properties at the FormCreate() event;

    Last: free the components at the FormDestroy() event.
    LVL 1

    Author Comment

    yea, that solution would work
    i don't like it thouhg.
    i lose all the advantages of using components - mainly being able to use object proprty editor to configure component at design time

    so there is absolutely no way to make delphi register some components associated with the project in the moment of opening this project?
    no delphi version is capable of doing that?
    LVL 12

    Expert Comment

    There is no way to install any components related only with a project. Installing components they appear into Delphi's IDE Component Palette and can be used with all the projects .... I am talking about Delphi up to version 7.
    But what could be the reason to hide components between the projects ?
    LVL 1

    Author Comment

    well, i'm working on projects that uses different version of the same components, so each time i switch to different proj i have to deinstall one set and install the other set of compomnents, have to remember about removing relevant *.bpl and *.dcu files from somwhere, it's just quite anoying...
    but well it seems i either have to live with it or create the components dynamically
    anyway, thanks for claryifing that
    LVL 12

    Expert Comment

    1). Working solution if you have free disk space enough (large physical HDD or HDD's). You may split for example a 80 GB HDD in 4 partitions 20 GB each .... Then install operational system for every of them, then Delphi for every of them and different components for every independent instance of Delphi .... This way you will work with different projects only after restart the computer and select the operational system where is the project you want to work with .... This works 100 %. I am working this way ....
    2). Possible solution if you create multi user installation of Delphi (Installations under different Windows user-names) .... I am not sure it will work, it depends on how is stored the information into the Windows Registry: is it independent for every user (without conflict) or not ????

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    860 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now