以生成一个TMemo的派生类及动态地创建该VCL控件为例。
Class TMemoEx : public TMemo
{
.
.
}
extern TMemoEx memoex;
Class TForm1 : Class TForm
{
public:
TMemoEx *MemoEx;
.
.
}
void _fastcall TForm1::FormShow(TObject *Sender)
{
MemoEx=new TMemoEx(this);
MemoEx->Parent=this;
.
.
}
总之,遵循以下步骤即可:
类定义;
extern TMemoEx memoex;
TMemoEx *MemoEx;
MemoEx=new TMemoEx(this);
MemoEx->Parent=this;
Class TMemoEx : public TMemo
{
.
.
}
extern TMemoEx memoex;
Class TForm1 : Class TForm
{
public:
TMemoEx *MemoEx;
.
.
}
void _fastcall TForm1::FormShow(TObject *Sender)
{
MemoEx=new TMemoEx(this);
MemoEx->Parent=this;
.
.
}
总之,遵循以下步骤即可:
类定义;
extern TMemoEx memoex;
TMemoEx *MemoEx;
MemoEx=new TMemoEx(this);
MemoEx->Parent=this;