R redstone Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #1 用new生成一个Form,在Form的Close事件中用delete释放出错。自己是不能释放自己的。怎么 解决?
R redhat2000 Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #4 procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Action :=caFree; Form1 :=nil; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Action :=caFree; Form1 :=nil; end;
R redstone Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #5 在该Form之外,用delete或free都行,问题是在想把程序写在Form内。
R redstone Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #6 to redhat2000: 请问 “Form1 :=nil” 的含义?
R redhat2000 Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #7 先把Form1所指的内存Free, 然后将Form1的指针指向空.
S Sachow Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #8 void __fastcall TForm1::Button1Click(TObject *Sender) { TForm2 *Form2; try{ Form2 = new TForm2(this); Form2->ShowModal(); } __finally{ delete Form2; Form2 = NULL; } }
void __fastcall TForm1::Button1Click(TObject *Sender) { TForm2 *Form2; try{ Form2 = new TForm2(this); Form2->ShowModal(); } __finally{ delete Form2; Form2 = NULL; } }
R redstone Unregistered / Unconfirmed GUEST, unregistred user! 2001-04-16 #9 ni1”是NULL,调试通过了。 谢谢hadhat2000.