Link to home
Start Free TrialLog in
Avatar of redsg
redsg

asked on

How do I import Units into a Delphi Project?

Hi,

I would like to use some current codes from an existing project to create a new DLL for future use. How can I import these current codes (in Units) into my DLL project?

I have tried using Project -> Add to Project, and selecting the Units that I want, but upon compilation, error messages were returned specifying that the .DFM files cannot be found. Is it necessary to have .DFM files when importing Units into a DLL project?

Your assistance will be much appreciated. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of ThievingSix
ThievingSix
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it looks like you will have common code between at least 2 projects

most of the time you start with common + project code in the same directory
you need to think about any other future projects too
and should try and mark the common units (.pas + .dfm) and place them in a separate directory

-- common code
-- project 1 code
-- project 2 code
-- project 3 code
-- big project 1
----subprojects specific common code
----subproject 1 code
----subproject 2 code

it will make your life a little harder to put the common units in the separate directories first
but for future projects it will make your life a lot easier

be aware that it takes some thinking to write common code
this common code should not need any units from the separate projects

you should be able to create a new project and use any units from the common code
without have to change anything to it for it to work in a new project
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of redsg
redsg

ASKER

Upon further inspection of the codes (I had actually just inherited them, so had not taken a good long look at them yet), I understand what TheivingSix and systan are talking about i.e. to ensure that the DFM files are included where the form components are being used. Will make the necessary inclusions while importing the Units.

Geert_Gruwez,
Understand the common code would be very useful for future projects, will keep it in mind.

Thanks guys!