Recent

Author Topic: [SOLVED] Issue with multiple forms  (Read 10411 times)

RobWitcher

  • New Member
  • *
  • Posts: 31
[SOLVED] Issue with multiple forms
« on: February 04, 2013, 08:11:10 pm »
Hi

I am making a program which requires at least three forms, some open at the same time. I have just added two forms to the first and I am already getting issues.
I added the forms, saved them into the same directory, added Unit2 and Unit3 to uses but when I try to make it visible (Form2.Visible:=True;) on creation of Form1 I get a popup message saying

Quote
Project project1 raised exception class 'External: SIGSEGV'. In file 'unit1.pas' at line 49: Form2.Visible:=True;

I can only assume I have made a stupid error but I cannot figure out what.
Any ideas?
« Last Edit: February 04, 2013, 08:29:13 pm by RobWitcher »
-Rob

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Issue with multiple forms
« Reply #1 on: February 04, 2013, 08:14:02 pm »
When you want to make Form2 visible try:

Code: [Select]
Form2.Show;

RobWitcher

  • New Member
  • *
  • Posts: 31
Re: Issue with multiple forms
« Reply #2 on: February 04, 2013, 08:18:09 pm »
When you want to make Form2 visible try:

Code: [Select]
Form2.Show;

That doesn't work either; it says

Quote
Project project1 raised exception class 'External: SIGSEGV'. In file '.\include\customform.inc' at line 2186

I don't have a clue what that means but it opens a new tab in the source editor and shows a lot of code with this

Quote
{------------------------------------------------------------------------------
  procedure TCustomForm.Show;
------------------------------------------------------------------------------}
procedure TCustomForm.Show;
begin
  Visible := True;
  BringToFront;
end;             

and has Visible := True; highlighted.
-Rob

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Issue with multiple forms
« Reply #3 on: February 04, 2013, 08:21:18 pm »
Are the forms auto-created?

What exactly means that:
Quote
when I try to make it visible (Form2.Visible:=True;) on creation of Form1

If you use the OnCreate event handler of Form1 to make other forms visible, of course they are not created yet.
« Last Edit: February 04, 2013, 08:26:56 pm by typo »

RobWitcher

  • New Member
  • *
  • Posts: 31
Re: Issue with multiple forms
« Reply #4 on: February 04, 2013, 08:28:53 pm »
OK, it was because I was showing them in the procedure TForm1.FormCreate;.
Thanks a lot.
-Rob

cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #5 on: March 02, 2013, 03:11:44 pm »
I am having exactly this problem.

Using Lazarus 1.0.4 r39423 FPC 2.6.0 x86_64-linux-gtk 2 on 12.10 on an XUbuntu box

I have Form3 which has a menu which, when selected, should activate Form4

procedure TForm3.MenuDBNewClick(Sender: TObject);
begin
  FormNewDB.show;
end; 

Instead I get the error "Project xxxx raised exception class 'External: SIGSEGV'. In file 'include/customform.inc' at line 2186" referred to by Rob.


howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: [SOLVED] Issue with multiple forms
« Reply #6 on: March 02, 2013, 05:35:02 pm »
SIGSEGV usually indicates that the instance you are referencing has not been created.
Is FormNewDB autocreated? i.e. is there an
Code: [Select]
  Application.CreateForm(TFormNewDB, FormNewDB);
call for it in your project's source .lpr?

cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #7 on: March 02, 2013, 11:17:14 pm »
No. That's odd.

There is no
Code: [Select]
Application.CreateForm(TFormNewDB, FormNewDB);entry in the project source.lpr.

How can I add this?

I've tried doing it manually, but that generates it's own errors.

wp

  • Hero Member
  • *****
  • Posts: 13266
Re: [SOLVED] Issue with multiple forms
« Reply #8 on: March 03, 2013, 12:18:43 am »
Quote
but that generates it's own errors
Which errors? Probably the form's unit is not mentioned in the lpr's "uses" clause.

Alternatively go to the project options, section "Forms". You should see the form in the list of "Available forms". Click on the "<-" button to move it to the list of "Auto-created forms".

cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #9 on: March 03, 2013, 06:49:28 am »
Code: [Select]
WoFlow.lpr(30,35) Error: Incompatible type for arg no. 1: Got "TFormNewDB", expected "TComponentClass"
application.inc(2149,24) Hint: Found declaration: TApplication.CreateForm(TComponentClass,out <Formal type>);
WoFlow.lpr(33) Fatal: There were 1 errors compiling module, stopping

On this line (which I added manually).

Code: [Select]
Application.CreateForm(FormNewDB, TFormNewDB);
This isn't actually the error produced last night, but it's as far as I can get this morning.

The .PAS file starts thus:
Code: [Select]
type

  { TFormNewDB }

  TFormNewDB = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Dbf1: TDbf;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    SelectDirectoryDialog1: TSelectDirectoryDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FormNewDB: TFormNewDB;             
« Last Edit: March 03, 2013, 06:52:10 am by cov »

wp

  • Hero Member
  • *****
  • Posts: 13266
Re: [SOLVED] Issue with multiple forms
« Reply #10 on: March 03, 2013, 12:01:36 pm »
Can you reproduce this behavior with a simple project that you can post here?

cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #11 on: March 03, 2013, 12:41:55 pm »
I don't think so, sorry.

The project was working fine but I had a couple of issues with circular references in the 'uses' section of the New Database form.

Once I sorted these out was when the errors started to occur.

I really doubt that I'd be able to reproduce this very easily, I'm afraid.

 %)

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: [SOLVED] Issue with multiple forms
« Reply #12 on: March 03, 2013, 02:17:46 pm »
Could you show the application source code, the .lpr file? That would verify to us that the forms are created.

cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #13 on: March 05, 2013, 04:43:21 pm »
Code: [Select]
program WoFlow;

{$MODE Delphi}

uses
  Forms, Interfaces,
  APassword in 'APassword.pas' {Form1},
  BCard in 'BCard.pas' {Form2},
  CDatabase in 'CDatabase.pas' {Form3},
  ExtractBlocks in 'ExtractBlocks.pas' {Form4},
  Basevars in 'Basevars.pas',
  reader in 'reader.pas',
  reader15 in 'reader15.pas',
  Vars in 'Vars.pas',
  Environments in 'Environments.pas' {Form6},
  newUser in 'newUser.pas' {fNewUser},
  newdbase in 'newdbase.pas' {FormNewDB};

begin
  Application.Initialize;
  Application.Title := 'Drawing File';
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm4, Form4);
  Application.CreateForm(TForm6, Form6);
  Application.CreateForm(TfNewUser, fNewUser);
  Application.CreateForm(FormNewDB, TFormNewDB);
  Application.Run;
end.                                   


cov

  • Full Member
  • ***
  • Posts: 246
Re: [SOLVED] Issue with multiple forms
« Reply #14 on: March 05, 2013, 04:49:06 pm »
I've started a new thread, not least because the subject has wondered from the original poster's problem, but also because this thread has been marked as [SOLVED].

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

 

TinyPortal © 2005-2018