Recent

Author Topic: Using a Form developed for a one Project into another Project.  (Read 2516 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

  • Hero Member
  • *****
  • Posts: 858
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 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

furious programming

  • Hero Member
  • *****
  • Posts: 858
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 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

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: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018