Board index » delphi » ShowModal problem

ShowModal problem

I have a problem using ShowModal (Delphi 2).

I am creating an instance of a form, and store it in a local
variable oDlg.

   try
      oDlg := TForm.Create(self,DatabaseName);
      oDlg.ShowModal;
   finally
      oDlg.Free;
   end;

When I try to show the form using its ShowModal method, I get
an exception saying that I can't make a visible window modal.
However, neither right before or right after the exception
occurs, the Visible property of the form is True.

This problem has happened to me in the past, but I never figured
out what I'm doing wrong. As far as I can tell, the relevant design
properties have the same value as those in other forms, which can be
opened modally without a glitch.

Any suggestions?

Frank (fgr...@glue.umd.edu)

 

Re:ShowModal problem


Quote
Frank Groen wrote:

> I have a problem using ShowModal (Delphi 2).

> I am creating an instance of a form, and store it in a local
> variable oDlg.

>    try
>       oDlg := TForm.Create(self,DatabaseName);
>       oDlg.ShowModal;
>    finally
>       oDlg.Free;
>    end;

> When I try to show the form using its ShowModal method, I get
> an exception saying that I can't make a visible window modal.
> However, neither right before or right after the exception
> occurs, the Visible property of the form is True.

> This problem has happened to me in the past, but I never figured
> out what I'm doing wrong. As far as I can tell, the relevant design
> properties have the same value as those in other forms, which can be
> opened modally without a glitch.

> Any suggestions?

> Frank (fgr...@glue.umd.edu)

Set the Visible Property to False for Modal Forms.

Regards,

Graeme

Re:ShowModal problem


Quote
Frank Groen wrote:

> I have a problem using ShowModal (Delphi 2).

> I am creating an instance of a form, and store it in a local
> variable oDlg.

>    try
>       oDlg := TForm.Create(self,DatabaseName);
>       oDlg.ShowModal;
>    finally
>       oDlg.Free;
>    end;

> When I try to show the form using its ShowModal method, I get
> an exception saying that I can't make a visible window modal.
> However, neither right before or right after the exception
> occurs, the Visible property of the form is True.

> This problem has happened to me in the past, but I never figured
> out what I'm doing wrong. As far as I can tell, the relevant design
> properties have the same value as those in other forms, which can be
> opened modally without a glitch.

> Any suggestions?

> Frank (fgr...@glue.umd.edu)

Oh I use a slightly different syntax to instantiate the class, ( Don't
know if that matters ) ?

 try
   Application.CreateForm( TDefaults, Defaults );
   Defaults.ShowModal();
 except
   Defaults.Free;
 end;

Regards,

Graeme

Other Threads