读书人

关于caFree有关问题

发布时间: 2012-06-12 14:21:25 作者: rapoo

关于caFree问题
程序如下:

void __fastcall TForm2::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if(RichEdit1 -> Modified)
{
int Choose = MessageDlg("您还没有保存文件,需要保存吗?",mtConfirmation,
TMsgDlgButtons() << mbYes << mbNo << mbAbort,0);
if(Choose == mrYes)
{ Form1 -> btnSaveClick(Sender);
if(RichEdit1 -> Modified)
CanClose = false;
}
else if (Choose == mrAbort)
CanClose = false;
else
Action = caFree;

}
}

运行时显示错误
[C++ Error] Unit2.cpp(34): E2034 Cannot convert 'TCloseAction' to 'TBasicAction *'
什么意思?,说下原理

[解决办法]
正确使用caFree
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
Action = caFree;
}

你代码中的Action 是指TForm 属性TBasicAction *Action
你的代码 最好放到
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose) 中
当然 Action = caFree; 放到FormClose 中。


读书人网 >C++ Builder

热点推荐