BCB中派生VCL類及動態(tài)地創(chuàng)建控件

字號:

以下不完整例子為生成一個tmemo的派生類及動態(tài)地創(chuàng)建該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;