Was du suchst sind dynamische Objekte.
So könnte dein Code beispielsweise aussehen:
Code:
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
TMemo *memo = new TMemo(Form1);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
memo->Parent = Form1;
memo->Visible = false;
memo->Position->X = 10;
memo->Position->Y = 10;
memo->Width = 200;
memo->Height = 140;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Button1->Text == "Erstellen") {
Button1->Text = "Löschen";
memo->Visible = true;
} else if (Button1->Text == "Löschen") {
Button1->Text = "Erstellen";
memo->Visible = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete(memo);
}
//---------------------------------------------------------------------------
Wenn der Kompiler anzeigt, dass er "TMemo" nicht kennt, einfach mal eines aus der Toolbox auf die Form ziehen, kompilieren und das Memo wieder löschen.