• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Project's own components

Hi,

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.

Thanks,
x-pander
0
x-pander
Asked:
x-pander
  • 4
  • 2
1 Solution
 
esoftbgCommented:
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;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  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;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ExExPanel1.Free;
  eCalendar1.Free;
end;

end.
0
 
esoftbgCommented:
First: declare the components into the public section of the TForm

//........
    public
      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.
0
 
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?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
esoftbgCommented:
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 ?
0
 
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
0
 
esoftbgCommented:
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 ????
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now