Kapusta
asked on
How to identify if a TForm is created yet and open?
I need a way for Form1 to know if Form2 is created and open. Form1 is my Main (auto-created) form. Form2 is created "on-the-fly" with a .Create method, and is then displayed with a .Show method. Form2 does NOT have a caption, BTW. How can I detect whether Form2 is created and open?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is what I am trying to do... do I need to add "Form2 := nil" as SteveB suggests?
procedure TForm1.Button1Click(Senter : TObject);
begin
Timer1.Enabled := True;
Form2:= TForm2.Create(Application) ;
try
Form2.ShowModal;
finally
Form2.Free;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if Assigned(Form2) then begin
Form2.Button1.Click;
end;
MessageDlg('Time is up!',mtInformation, [mbOk], 0);
end;
I want to force the Form2 to close SHOULD it be open when the timer on Form1 triggers.
procedure TForm1.Button1Click(Senter
begin
Timer1.Enabled := True;
Form2:= TForm2.Create(Application)
try
Form2.ShowModal;
finally
Form2.Free;
end;
end;
procedure TForm1.Timer1Timer(Sender:
begin
Timer1.Enabled := False;
if Assigned(Form2) then begin
Form2.Button1.Click;
end;
MessageDlg('Time is up!',mtInformation, [mbOk], 0);
end;
I want to force the Form2 to close SHOULD it be open when the timer on Form1 triggers.
Steven.