Solved

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

Posted on 2003-11-03
1
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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