TOutlineNode (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

 This example shows how to load the content of a text file (or a stream)
 into a TOutline object and how to save the content of the outline into a
 text file (or a stream).

TMemoryStream* TempStream;


Code

__fastcall TMainForm::TMainForm(TComponent* Owner)
	: TForm(Owner)
{
  /* Create a memory stream */
  TempStream = new TMemoryStream;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btLoadClick(TObject *Sender)
{
  /* Load the content of the input file in the first outline */
  Outline1->LoadFromFile("input.txt");
  /* Save the content of the outline in the memory stream */
  Outline1->SaveToStream(TempStream);
  /* Move the pointer at the begining of the stream */
  TempStream->Seek(0, soFromBeginning);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btSaveClick(TObject *Sender)
{
  /* Load the content of the stream in the second outline */
  Outline2->LoadFromStream(TempStream);
  /* Save the content of the outline in the output file */
  Outline2->SaveToFile("output.txt");
  delete TempStream;
}

Uses