Solved

Reloading a form. How?

Posted on 2000-04-01
5
206 Views
Last Modified: 2010-04-02
I am using BorlandC++ Builder3.

How do I reload a form I am using from the click event of a button on that form.  In other words get the form set up as it was at the start.I am using New and Delete when creating and destroying forms. I have the forms set to manual. If I new the form and then delete, I just get back the original with everything on it. If I delete and then new it crashes as you would expect.
Can anyone help?
0
Comment
Question by:ttel
[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
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ntdragon
ID: 2676788
here is an idea for you

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TForm *f;
   f=Form1;
   Form1=new TForm1(Form1);
   Form1->Tag =1;
   Form1->Show();
}
//---------------------------------------------------------------------------

now you know that the first form got 0 in the tag and the reset 1
so you can delete only if the tag is 1
so you can make the first invisible
and delete the reset
0
 

Author Comment

by:ttel
ID: 2677524
I cannot get this to work properly.
I do not want to make the first form invisible, I want to delete it altogether so that I can display the new form with various graphics in their original places and other controls with their properties reset.

I tried

delete f;

f being the old form.
However it crashed.

Thanks for the advice
Can you give me any more advice.
I think this may be a tough one!!
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2677783
as i know if you"ll close the main form
<that is set in the project opetions>
the program will close

so you have two opetions
1)to make the first invisible as i said
2)to make another for as the main and make it invisible and then to create from it your form using new and deleting it using delete

0
 

Author Comment

by:ttel
ID: 2678284
I am not dealing with the Main Form.
The problem is when I try to delete the original form the copy is deleted and I am left with the original.
How do I distinguish between the two forms so that I can delete the originaland leave the copy or should I say the new form?
0
 
LVL 1

Accepted Solution

by:
ntdragon earned 20 total points
ID: 2679319
i can say it again in your prog the original form is the main form
so you can't delete it the prog will close if you will

so i told you how you can overcome this prob
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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

717 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