Recent

Author Topic: [SOLVED]Adding Existing Forms to a Project.  (Read 15695 times)

cov

  • Full Member
  • ***
  • Posts: 241
[SOLVED]Adding Existing Forms to a Project.
« on: March 05, 2013, 04:46:40 pm »
I've got an application that has somehow borked.

http://www.lazarus.freepascal.org/index.php/topic,19811.0.html

The solution would appear to be to start a new Project and add all the Forms and Units from the borked Project into the new one.

However, I can't see how to do this.
« Last Edit: March 06, 2013, 10:22:53 am by cov »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Adding Existing Forms to a Project.
« Reply #1 on: March 05, 2013, 04:59:04 pm »
Open the forms/code with the respective file/open menu commands.

Go to project inspector, add files, tab editor files, select all files, click add to project

(something like this, going on memory here)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

cov

  • Full Member
  • ***
  • Posts: 241
Re: Adding Existing Forms to a Project.
« Reply #2 on: March 06, 2013, 09:10:19 am »
Sorry for the stupid question.

Obviously all you do is refer to the new unit in the 'uses' section of one of the PAS units and the new unit is pulled in to the Project together with it's form.

 :-[

cov

  • Full Member
  • ***
  • Posts: 241
Re: Adding Existing Forms to a Project.
« Reply #3 on: March 06, 2013, 09:36:39 am »
Hmm.

Form3.Visible=True;

Now gives me an error:

Quote
Project CADCab raised exception class 'External: SIGSEGV'.

 In file 'apassword.pas' at line 71:
Form3.Visible:=True;

The first form is a login form which, if a correct password is proffered, calls Form3. However, it doesn't appear that  Form3 has been built.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Adding Existing Forms to a Project.
« Reply #4 on: March 06, 2013, 09:48:18 am »
The first form is a login form which, if a correct password is proffered, calls Form3. However, it doesn't appear that  Form3 has been built.

You can create the form in your code, or you can let the project auto-create it.
In Lazarus IDE, see Project Options -> Forms.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

cov

  • Full Member
  • ***
  • Posts: 241
Re: Adding Existing Forms to a Project.
« Reply #5 on: March 06, 2013, 10:01:01 am »
Okay, thanks Juha.

The Options->Forms doesn't have Form3 in the 'Available Forms' pane. How do I get it into the Project?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Adding Existing Forms to a Project.
« Reply #6 on: March 06, 2013, 10:06:22 am »
Simple solution to the error is, not trying to manipulate other forms in the onFormCreate event. You propably have a loading order error, where password form is created before form3. It will throw SIGSEGV because that form is null. It can be solved by using onFormShow for example, just making sure that it only happens once.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Adding Existing Forms to a Project.
« Reply #7 on: March 06, 2013, 10:14:32 am »
The Options->Forms doesn't have Form3 in the 'Available Forms' pane. How do I get it into the Project?

BigChimp tried to explain it. However the easiest way is, when the file is open in editor :
  Project -> "Add Editor File to Project"

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

cov

  • Full Member
  • ***
  • Posts: 241
Re: Adding Existing Forms to a Project.
« Reply #8 on: March 06, 2013, 10:19:13 am »
Okay, I see.

If the PAS unit it open in the source editor, then the associated Form appears in the Autocreate pane.

Many thanks!

I'll just test it, and if there are no more hitches, I'll mark the thread as solved.

cov

  • Full Member
  • ***
  • Posts: 241
Re: [SOLVED]Adding Existing Forms to a Project.
« Reply #9 on: March 06, 2013, 10:25:18 am »
Just to add that the Form needs to be called up as well before it shows up in the Autocreate Form pane.

(Press F12 while the associated PAS unit it up on the editor).

Many thanks to BigChimp and Juha. Thanks guys!

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: [SOLVED]Adding Existing Forms to a Project.
« Reply #10 on: March 06, 2013, 11:06:50 am »
Just to add that the Form needs to be called up as well before it shows up in the Autocreate Form pane.
(Press F12 while the associated PAS unit it up on the editor).

Sounds like a bug. Did you add the file to your project for sure?
Check : Project -> Project Inspector

One more note about autocreating forms:
In a small project it is OK to autocreate all forms but not so in a big project.
Many forms are used only seldom. A form may not be needed at all during a user's work session.
Autocreating such forms slows down the startup and reserves memory.
Then it is better to create the form in code when needed and free it afterwards.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018