1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| //---------------------------------------------------------------------------
void __fastcall TFEditionEssai::SaveEssai (AnsiString FileName)
{
FILE *hf ;
TTreeNode* NodeEssai ;
PStructEssai DEssai;
PStructCycleRef DCycleRef;
PStructPasTemp DPasTemp;
PStructSauv DSauv ;
PStructCycleEnd DCycleEnd;
PStructPasEnd DPasEnd;
int MyNodeType ;
hf = fopen (FileName.c_str(), "w+b") ;
if (hf == NULL)
{
ShowMessage(strerror(errno));
return ;
}
TTreeNode *CurItem = TreeViewCycle->Items->GetFirstNode();
while (CurItem)
{
MyNodeType = CurItem->ImageIndex;
switch (CurItem->ImageIndex )
{
case ntEssai:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DEssai = new TStructEssai;
DEssai = PStructEssai(CurItem->Data);
fwrite (DEssai, sizeof (TStructEssai), 1, hf) ;
break ;
case ntCycleRef:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DCycleRef = new TStructCycleRef;
DCycleRef = PStructCycleRef(CurItem->Data);
fwrite (DCycleRef, sizeof (TStructCycleRef), 1, hf) ;
break ;
case ntPasTemp:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DPasTemp = new TStructPasTemp;
DPasTemp = PStructPasTemp(CurItem->Data);
fwrite (DPasTemp, sizeof (TStructPasTemp), 1, hf) ;
break ;
case ntCycleEnd:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DCycleEnd = new TStructCycleEnd;
DCycleEnd = PStructCycleEnd(CurItem->Data);
fwrite (DCycleEnd, sizeof (TStructCycleEnd), 1, hf) ;
break;
case ntSauvegarde:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DSauv = new TStructSauv;
DSauv = PStructSauv(CurItem->Data);
fwrite (DSauv, sizeof (TStructSauv), 1, hf) ;
break ;
case ntPasEnd:
fwrite (&MyNodeType , sizeof (int), 1, hf);
DPasEnd = new TStructPasEnd;
DPasEnd = PStructPasEnd(CurItem->Data);
fwrite (DPasEnd, sizeof (TStructPasEnd), 1, hf) ;
break;
}
CurItem = CurItem->GetNext();
}
if (hf)
fclose (hf) ;
} |
Partager