Solved

How to use Assigned as a check for a dynamicly created form.

Posted on 2003-11-03
1
165 Views
Last Modified: 2012-05-04
On my mainform I have a button to create another form as below

procedure TfrmMain.btn_NewfrmClick(Sender: TObject);
begin
  if not Assigned(myform) then
    begin
      myform := TmyForm.Create(frmMain);
      myform.FormStyle := fsStayOnTop;
      myform.Show;
    end;
end;

The new myform is created fine.

The OnClose of myForm contains:

procedure TmyForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
  myForm := nil;
end;

My question is: If I try to open the form a second time then I cannot.
It appears that the call (myForm := nil) in myForm doesn't actually set
myForm to nil;

Any help would be most appreciated.
-Rick
0
Comment
Question by:rickluttrell
1 Comment
 
LVL 4

Accepted Solution

by:
brunomsilva earned 250 total points
ID: 9672704
where do you have the myform variable defined? place it before the implementation section of the mainform.
It works with me.

Bye,
 Bruno
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now