Solved

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

Posted on 2003-11-03
1
164 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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

10 Experts available now in Live!

Get 1:1 Help Now