본문 바로가기
코드

[BCB] HtmlElements - TTreeView

by umaking 2008. 7. 10.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
 //
 AnsiString c1, c2;
 GetTextFile("c:\\ssr.txt", c1);
   
 Memo1->Lines->Clear();
 Memo1->Lines->Add(c1);

 TTreeNode *node;
 node = TreeView1->Selected;
 int stPos, edPos;
 int cnt = 0;
 AnsiString tmp = c1;
 AnsiString tmp2, tmp3;
 
 while((stPos = tmp.AnsiPos("<")) > 0 && (edPos = tmp.AnsiPos(">")) > 0) {
  tmp2 = tmp.SubString(stPos, edPos);
  TreeView1->Items->Add(node, tmp2);
  tmp = tmp.SubString(edPos+1, tmp.Length()-edPos+1);
 }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::GetTextFile(AnsiString fileName, AnsiString &buff)
{
 TFileStream *f = new TFileStream(fileName, fmOpenRead);

 buff.SetLength( f->Size );
 f->Read( buff.c_str() , f->Size);

 f->Free();
}