• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

How to make form modal


How can I make a Delphi form modal, so the "underlaying" form(s) is/are blocked....

Alk
0
roczalk
Asked:
roczalk
1 Solution
 
robert_marquardtCommented:
Somewhere you call Form.Show. Replace by Form.ShowModal.
0
 
kretzschmarCommented:
yep, thats it
0
 
VSFCommented:
if your form is not created automatically at runtime just do:

Procedure TForm1.Button1Click(Sender: TObject);
begin
 application.createform(TForm2, Form2);
 Form2.Showmodal;
end;

It is important to remember that modal forms can not be MDiChild and they will stay on top until you call the form's OnCloseEvent:

Action:=CaFree;


Hope it helps!
VSF
www.victory.hpg.com.br
www.boatoda.hpg.com.br
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
kretzschmarCommented:
hmm,

i usual use something like this

begin
  with tFormWhichShouldBeShowedModal.create(self) do
  try
    showmodal;  
    //or if modalresult is needed
    //mres := showmodal;
    //
    //maybe transport some values from the form
    //for further process
    somevar := EditControlOnModalForm.text;
  finally
    release;
  end;
end;
   
meikl ;-)
0
 
robert_marquardtCommented:
Do not call CreateForm. Create is good enough.
0
 
roczalkAuthor Commented:
Thanks all for the response.
I did indeed find the ShowModal, but was surprised I couldn't place this setting on the form properties itself.

As Robert was the first with th esolution, I'll reward him with the points, but I'm also gratefull for the other comments. Thanks guy's ;-)

Alk
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now