Board index » delphi » TPanel *TP = new TPanel (Form1);

TPanel *TP = new TPanel (Form1);

Can anyone tell me what I'm doing wrong here?  I get a memory access error
at runtime.

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
      TPanel *TPArray = new TPanel (Form1);
      TPArray->Parent = Form1;
      TPArray->Left = 16;
      TPArray->Top  = 20;
      TPArray->Width = 200;
      TPArray->Height = 110;

Quote
}

Thanks in advance.

Roger {*word*163}

 

Re:TPanel *TP = new TPanel (Form1);


Quote
"roger" <ro...@r{*word*163}.com> writes:
> Can anyone tell me what I'm doing wrong here?  I get a memory access error
> at runtime.

> __fastcall TForm1::TForm1(TComponent* Owner)
> [snip]

This looks like VCL code, i.e. you seem to be using C++ Builder. But this
newsgroup is about Borland C++.

Please direct your browser at http://www.borland.com/newsgroups and read the
newsgroup descriptions and guidelines. This will help you find the appropriate
newsgroup for your question.

Re:TPanel *TP = new TPanel (Form1);


roger schrieb:

Quote
> __fastcall TForm1::TForm1(TComponent* Owner)
>   : TForm(Owner)
> {
>       TPanel *TPArray = new TPanel (Form1);
>       TPArray->Parent = Form1;
> ...

Try :
       TPanel *TPArray = new TPanel(this);
       TPArray->Parent = this;

bye Chris

Other Threads