dynamic object creation in borland c++ builder

Started by
6 comments, last by GameDev.net 19 years, 6 months ago
does anyone know the code to create something dynamically in borland ex. when i press a button create a panel... it uses something like new TPanel Parent Form1 i really dont know, but i forgot it and i cant find it in any of my projects that i have done. could someone help me plz thanks
C++ ProgrammerAIM - GT70sgtLead Guitar in Distorted Play
Advertisement
i know that it is something like

global:

TPanel* Panels[10];
int x = 0;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Panels[x] = new TPanel();
x++;
}
/------------------------------------------

i tried that but it gives me an error for the TPanel thing

even if i try

Panels[x] = new TPanel(Panels[x]);


it runs!
but it doesnt work... :(

help plz...
C++ ProgrammerAIM - GT70sgtLead Guitar in Distorted Play
what, nobody can reply, geeze....


really, i need some help with this, i have tried everything i know....
C++ ProgrammerAIM - GT70sgtLead Guitar in Distorted Play
Did you try looking at the help on TPanel? It says specifically that you need to specify an owner. That's either another component or a window. Where is this panel suppose to be created? What is it part of? Is it just a panel on the desktop? If so then you at a minimum need to tell it to create it on the desktop if that would even work.
Keys to success: Ability, ambition and opportunity.
i know, i have to create it on the form...thats why i said it has something to do with Parent Form1 and what not

you didnt help me, i have looked in every help file i have, and all it says is

Panel1 = new TPanel();

thats it....its not just panel or anything...its any object

Image1 = new TImage();
Button1 = new TButton();

anything....if you use borland you would know what im trying to say...
IIRC, when i used Delphi (it uses almost same VCL) , i had to create it passing parent, and maybe also make it visible.. something like show(). But i don't sure, i have never used VCL really much.
Hi GT70sgt,

Something like this should help you out, its been a while but I used to use BCB myself :)

 TPanel *Panel1 = new TPanel(this); Panel1->Parent = this; Panel1->Name = "PANELCOMPONENT"; Panel1->Caption = "BLAH"; Panel1->Left = 10; Panel1->Top = 10; Panel1->Width = 150; Panel1->Height = 50; Panel1->Show();


Dont forget to delete the panels you create - if you need any more help just let me know

Chris.
ohh yes, its this...lol, thanks, i remember it now.

thanks lots man


peace

This topic is closed to new replies.

Advertisement