Solved

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

Posted on 2003-11-03
1
168 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 105
Delphi...Split view - idea? 1 113
Tvertscrollbox like a whatsapp layout 5 50
migrate this code to work on android 1 27
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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