[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Has a form already been loaded?

Posted on 2001-08-22
8
Medium Priority
?
180 Views
Last Modified: 2012-05-04
Is there a way of telling whether or not a form has already been loaded?

I'm writing an app with various forms that the user can open, but I only want the user to be able to open each form once. If it's already open, I just want to bring it to the front instead of loading another copy of it.

Cheers
0
Comment
Question by:riccohb
[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
  • 5
  • 3
8 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 6413413
use findcomponent or iterate through the screen.forms-list
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6413427
or was it application.forms?
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6413517
if Assigned(TheForm) then
 TheForm.Show
else begin
 TheForm := TForm.Create(nil);
 TheForm.Show;
end;

make sure you free the form before you the app terminates.


The Crazy One
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6413548
assigned will not work in all cases :-(
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6413579
Hi meikl
Really hmm please explain. I haven't found it to be a problem when dealing with forms internal to the application. :>)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6413643
crazy,

just try

...
form1 := tform1.create(self);
form1.free;
if assigned(form1) then  //you will go into the then way
...

better way
...
form1 := tform1.create(self);
FreeAndNil(form1);
if assigned(form1) then  //you will not go into the then way
...

its just that assigned isn't other than objectvar <> nil and free do not nil the objectvar

riccohb,

glad to helped you,
thanks for the points :-)

meikl ;-)
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6413815
Ah hah and there you go. I forgot that I always set the form variable to nil when freeing it so that is why I don't have a problem. I just got in the habit of doing it that way that I forgot about it and assumed that the nil was automatic. Duh. hehehe

Thanks meikl for the reminder. :>)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6416420
:-))
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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