Solved

Reloading a form. How?

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now