Recent

Author Topic: Using a Form developed for a one Project into another Project.  (Read 1214 times)

DenPit5

  • New Member
  • *
  • Posts: 21
I have a form in a previous project which I developed which I would like to incorporate in another project I am working on.  Is it possible to load this into the new project ?   If so can anyone explain how to load it.?

furious programming

  • Sr. Member
  • ****
  • Posts: 354
  • I click a little.
Re: Using a Form developed for a one Project into another Project.
« Reply #1 on: March 03, 2019, 04:57:52 pm »
Open your current project, then open the Project Inspector window, click the Add button and click the Add Files from File System menu item. Then, in the open dialog, select the form's .pp file. Recompile the project. That's all.

To use this form, add the unit name to the uses section of the given unit.
Lazarus 2.0.4 with FPC 3.0.4, Windows XP (all 32-bit)

lucamar

  • Hero Member
  • *****
  • Posts: 2079
Re: Using a Form developed for a one Project into another Project.
« Reply #2 on: March 03, 2019, 05:50:48 pm »
Do note that following "furious programming" instructions to the letter means that any change to the form in the second project will be reflected in the original one. If you don't want that to happen simply copy the .lfm and .pas from the original folder to the second and add these later to the second project.
« Last Edit: March 03, 2019, 05:53:03 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

furious programming

  • Sr. Member
  • ****
  • Posts: 354
  • I click a little.
Re: Using a Form developed for a one Project into another Project.
« Reply #3 on: March 03, 2019, 07:18:48 pm »
Do note that following "furious programming" instructions to the letter means that any change to the form in the second project will be reflected in the original one.

I think it's logical and that the questioner knows about it. :D
Lazarus 2.0.4 with FPC 3.0.4, Windows XP (all 32-bit)

DenPit5

  • New Member
  • *
  • Posts: 21
Re: Using a Form developed for a one Project into another Project.
« Reply #4 on: March 05, 2019, 08:40:50 pm »
Many thanks Furious & Lucamar for your replies. I carried out your instructions and got the Form & Unit into the other project but unfortunately when I tried  to compile the result it through out an error ' Duplicated Form'. Compile again using -vd for more details.  I am not sure how to do this so I remain stymied ???

lucamar

  • Hero Member
  • *****
  • Posts: 2079
Re: Using a Form developed for a one Project into another Project.
« Reply #5 on: March 05, 2019, 09:12:55 pm »
Do the forms have the same name? I mean, if the normal form is:
Code: Pascal  [Select]
  1. TForm1 = class(TForm)
  2.   {..etc...}

and the form from the other project is identicaly declared then you'll have to change the name of one of them.

You can do that either of two ways:
  • In the object inspector, select the form and change the property "Name"
  • Edit both the .lfm and the .pas of the form and change the name there. You'll probably have to edit also the projectX.lpr if the form is auto-created

ETA: Although I guess that would give problems much earlier that when compiling ...
« Last Edit: March 05, 2019, 10:05:22 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.