//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TListRemove.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TListRemove
// Method: Classes.TList.Remove
// Routine: Dialogs.MessageDlg

// BeginCode
/*
The following code adds a new object to a list in a list
object and then removes it:
*/
#include <memory>       //for STL auto_ptr class

class TMyClass : public TComponent
{
__published:	// IDE-managed Components
private:	// User declarations
public:		// User declarations
  AnsiString MyString;
	__fastcall TMyClass(TComponent* Owner, AnsiString mystr);
};

__fastcall TMyClass::TMyClass(TComponent* Owner, AnsiString mystr)
	: TComponent(Owner)
{
  MyString = mystr;
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  std::auto_ptr<TList> list(new TList);
  TMyClass *TheObject = new TMyClass(Form1, "This is an object."); // The owner will clean this up;
  list->Add(TheObject); // add AnsiString instance to list
  MessageDlg("The list has " + IntToStr(list->Count) + " objects",
	mtInformation, TMsgDlgButtons() << mbOK, 0);
  list->Remove(TheObject);
  MessageDlg("The list has " + IntToStr(list->Count) + " objects",
	mtInformation, TMsgDlgButtons() << mbOK, 0);
}
// EndCode
// EndExample: TListRemove
//---------------------------------------------------------------------------
