Solved

Reloading a form. How?

Posted on 2000-04-01
5
204 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

773 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