Saving TFrame Properties


2004-07-08 09:13:44 AM
cppbuilder108
Hi, Good Morning! (Afternoon, or Evening?)
How do I save a TForm?
void __fastcall TForm1::SaveToFile(AnsiString fname)
{
TMemoryStream* pms = new TMemoryStream();
TFileStream* pss = new TFileStream(AFileName,fmCreate);
try{
//pms->WriteComponent(this);
for(int i = 0;i < ControlCount;i++){
// CRAMASコントロールが管理するラベルは除外する。(ゴリゴリ@)
if( Controls[i]->ClassNameIs("TLabel") &&
((TLabel*)Controls[i])->FocusControl != NULL) continue;
// Trackerオブジェクトは除外する。(ゴリゴリA)
if(Controls[i]->ClassNameIs("TTrack")) continue;
if(Controls[i]->ClassNameIs("TTrackRun")) continue; // jet 01.19.2004
// (FTSP)dan 2002/10/17
if(!IsValidControl(Controls[i])) continue;
Controls[i]->Left += HorzScrollBar->Position;
Controls[i]->Top += VertScrollBar->Position;
pms->WriteComponent(Controls[i]);
Controls[i]->Left -= HorzScrollBar->Position;
Controls[i]->Top -= VertScrollBar->Position;
}
pms->Seek(0, soFromBeginning);
while(pms->Position < pms->Size){
ObjectBinaryToText(pms, pss);
}
mFileName = AFileName;
mModified = false;
}
catch(...){
ShowMessage("Streaming error.");
}
delete pms;
delete pss;
}