Board index » cppbuilder » adding components at runtime

adding components at runtime

How do i add components to a form at run-time?
 

Re:adding components at runtime


On Thu, 2 Dec 1999 07:25:34 -0600, "Richard Garand"

Quote
<krogoth2?hotmail.com> wrote:
>How do i add components to a form at run-time?

Hi Richard,

    you could try something like this:

class TForm1 : public TForm
{
................
...............
private:
        TButton* Btn;
................
...............
        void __fastcall TForm1::AddButton( void );
................
...............

Quote
};

void __fastcall TForm1::AddButton( void )
{
    Btn = new TButton( this );
    Btn->Parent = this;
    Btn->Top = ....;
    Btn->Left = ....;
    Btn->Caption = ....;
    Btn->Hint = ....;
    etc etc

Quote
}

Instead of use a pointer like Btn, you could add the addresses
of yours new  components to a container if you have to create
more than one component.

HTH

Regards

Giuliano

Re:adding components at runtime


hello,

i think you want to add a component to a form depending on some actions
the user of your application does. if i am right in what your thinking,
you just add the component like this:

TEdit* pEdit = new TEdit(this);
pEdit->Parent;

and so on.

Frank

Richard Garand schrieb:

Quote
> How do i add components to a form at run-time?

Other Threads