Solved

Reloading a form. How?

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
White board coding practice 3 95
max float value 3 59
c++, dynamic object by json 1 60
How to Correctly derive class from CWinThread in MFC 4 89
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

749 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