how to check if a form has been created in c++

Posted on 2003-03-31
Medium Priority
Last Modified: 2006-11-17
Borland C++ Builder 5

How can I check if a Form has been created? if it exists?
Somewhere I do:

Form4 = new TForm4(this);

Meanwhile program is doing other stuff including displaying variables on Form4 but has to do this ONLY if Form4 exists.

Anyone can help me out?

Question by:djek2000
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

Accepted Solution

dede82 earned 200 total points
ID: 8266468

If Form4 is a pointer of TForm4, and I think it is since you're using "new" to create it, you can verify that the form exist by checking if our pointer is Null:

  if (Form4 != NULL)
    //displaying variables on Form4

If you are doing this test outside of the fonction in witch the Form4 was created, Form4 must be a global variable. So it a to be declare in your .h file with  #include <the unit containing TForm4>

It work fine for me on C++ Builder 6 so it will probably work on C++ Builder 5.

Hope this is what you were looking for.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

771 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