Recent

Author Topic: Main Form will not call a new form with ShowModal  (Read 395 times)

CarmichaelJohn

  • New Member
  • *
  • Posts: 38
Main Form will not call a new form with ShowModal
« on: July 14, 2020, 01:00:55 am »
Hello,
If I am in the wrong forum to ask this please excuse me.
I am having difficulty in getting the main unit/form in my program
to call another form using ShowModal. I have placed the new form’s
name in the uses clause of the main form.  Yet the program will
successfully execute and the main form shows up.  Then when I
click on the menu item for the new form I get an error message:
“Project project (my project’s name) raised exception class
‘External:SVGSEGV’.  The called form is called ‘Form9', and the
call statement looks as follows:
“procedure TForm1.MenuItem11Click(Sender: TObject);
begin
  //
  Form9.ShowModal;
  //
end;“

I built the program several days ago and then went back to it to add
this new form.  Is there a formal “Add to Program” or “Add to Project”
that I am missing, or is there something else that I must do to have
the main form recognize Form9.
Thank you in advance for any help you might provide,
John

RAW

  • Hero Member
  • *****
  • Posts: 867
Re: Main Form will not call a new form with ShowModal
« Reply #1 on: July 14, 2020, 01:25:14 am »
Try this:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormClick(Sender: TObject);
  2. begin
  3.   Form9:= TForm9.Create(Self);
  4.   Form9.SetBounds(0,0,Width,Height);
  5.   Form9.ShowModal;
  6. end;

Or maybe better like this ...  :)

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormClick(Sender: TObject);
  2. begin
  3.   Form2 := TForm2.Create(nil);
  4.   try
  5.     Form2.SetBounds(0, 0, Width, Height);
  6.     Form2.ShowModal;
  7.   finally
  8.     Form2.Release;
  9.     Form2 := nil;
  10.   end;
  11. end;
« Last Edit: July 14, 2020, 05:04:53 am by RAW »
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 2.0.8 FPC 3.0.4 - TRUNK 2.1.0 FPC 3.3.1
// This is polarity (hell) and hell is reigned by lies, nothing but lies. Be careful what you believe ...
// There are 10 types of people in this world, those who understand mind control and ...

Blaazen

  • Hero Member
  • *****
  • Posts: 2994
  • POKE 54296,15
    • Eye-Candy Controls
Re: Main Form will not call a new form with ShowModal
« Reply #2 on: July 14, 2020, 01:25:26 am »
@  I have placed the new form’s name in the uses clause of the main form.

Actually, there must be name of the unit where the form is defined.

But SIGSEGV indicates that Form9 is not created. Look at the *.lpr file of your project. There must be something like this:
Code: Pascal  [Select][+][-]
  1. Application.CreateForm(TForm9, Form9);

Also, that form must be Visible:=False; (set it in Object Inspector).
Lazarus 2.1.0 r64115 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

CarmichaelJohn

  • New Member
  • *
  • Posts: 38
Re: Main Form will not call a new form with ShowModal
« Reply #3 on: July 14, 2020, 02:22:51 am »
Blaazen and Raw,
Thank you both so much for this information.  Now I know and will be able to avoid this problem in the future.  I very much appreciate you're taking the time and effort to help me.
John

 

TinyPortal © 2005-2018