Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with MDI application

Status
Not open for further replies.

LastCyborg

Programmer
Feb 7, 2003
256
MX
I'm programming a MDI application, every ChildForm has code on an event just like this
onCreate()
{
Evaluator = new TEvaluator ();
}

onClose ()
{
delete Evaluator;
}

I have not problem with this, the problem consist that if I create 2 or more ChildrenForms, when I close the 2nd child I got an error EAcces memory.

I thought that every child is an object with his own memory space and if I close one of them the others objects (ChildWindows) don't should have problems.

so what I'm doing wrong.

Note: you can check this
copying this code to a MDIChild form

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Button1 = new TButton (this);
}
//--------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete Button1;
}



---LastCyborg---
 
create and initialize the objects outside of the mdichild form. destroy the object before you destroy the mdichild.

although you have to devise a method to associate the button or evaluate with the appropriate mdichild.


these may be worth looking into.
ActiveMDIChild
MDIChildren[x]


void __fastcall TMainForm::CreateMDIChild(String Name)
{
TMDIChild *Child;

//--- create a new MDI child window ----
Child = new TMDIChild(Application);
Child->Caption = Name;

TButton *Button1;
Button1 = new TButton (this);
Button1->Parent = Child;
}

void __fastcall TMainForm::FileNewItemClick(TObject *Sender)
{
CreateMDIChild("NONAME" + IntToStr(MDIChildCount + 1));
}

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top