The AutoCreate business probably set the visible property of the form to
true.

Try setting it to false, then your showmodal should work.

----- Original Message -----
From: "Mark Derricutt" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Tuesday, August 20, 2002 9:07 PM
Subject: [DUG]: Strange TTimer/ShowModal behaviour (kylix)


> 'lo all, have a strange problem afflicting a kylix 2 application.
>
> Take a project with 2 forms, Form1 & Form2, put a TTimer on Form1, and
give
> it the following code:
>
>   procedure TForm1.Timer1Timer(Sender: TObject);
>   begin
>     Form2.ShowModal;
>     Caption := 'Boo';
>   end;
>
> Form2 displays, but shortly afterwards, about a second, Form1's caption is
> set to Boo, whilst the modal form is still displayed.
>
> I've just tried the exact same thing under Delphi 5, and shortly after
> Form2 is displayed, I get an exception saying "EInvalidOperation with
> message 'Cannot make a visible window modal".
>
> I noticed that Form2 was still in the AutoCreate list, removing it, and
> creating/freeing a TForm2 instance in the timer solved the problem in both
> the Delphi and Kylix versions.
>
> But why is this?  When Form2 was being autocreated, it wasn't being shown,
> so why would ShowModal cause problems?
>
> Mark
>
>
>
>                                     -- \m/ --
>   "...if I seem super human I have been misunderstood." (c) Dream Theater
>          [EMAIL PROTECTED] - ICQ: 1934853 JID: [EMAIL PROTECTED]
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>
>


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to