Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reloading a form. How?

Posted on 2000-04-01
5
Medium Priority
?
208 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 80 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

598 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