Project's own components


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.

Who is Participating?
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.
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);

x-panderAuthor Commented:
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?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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 ?
x-panderAuthor Commented:
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
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 ????
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.