I often disable/reenable the timer in Timer1.OnTimer. This prevents the timer from kicking in when you don't want it to:
procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Enabled:= FALSE; try Form2.ShowModal; Caption := 'Boo'; finally Timer1.Enabled:= TRUE; end; end; > I get an exception saying "EInvalidOperation with message 'Cannot make a visible window modal". I would expect this to occur if ShowModal was in a timer as below. Cheers '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 --------------------------------------------------------------------------- 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/