 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jonathan Arnold Guest
|
Posted: Sat Nov 22, 2003 1:07 am Post subject: TPageControl help file example |
|
|
Here's the example in the Help docs for TPageControl:
#include <Comctrls.hpp>
TPageControl* ppc;
TTabSheet* pts[MAXTABS];
const char * ppcTabTitles[] = { "ShortString", "Orders", "Items", "Parts" };
int iTabTitles = sizeof(ppcTabTitles)/sizeof(ppcTabTitles[0]);
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ppc = new TPageControl(this);
ppc->Parent = this;
ppc->Align = alClient;
for (int i=0;i<iTabTitles;i++)
{
pts[i] = new TTabSheet(this);
pts[i]->PageControl = ppc;
pts[i]->Name = AnsiString("pts") + ppcTabTitles[i];
pts[i]->Caption = ppcTabTitles[i];
}
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
for (int i=0;i
delete pts[i];
delete ppc;
}
To begin with, of course, it is using FormCreate and FormDestroy - no-no
in C++Builder. But I also wonder about the deletes. I thought that the
owner was responsible for deleting, so the "new TPageControl(this)" sets
the owner to be the form, and it will be responsible for deleting it.
Isn't that right?
--
Jonathan Arnold C/C++/CBuilder Keen Advice:
http://www.keen.com/categories/categorylist_expand.asp?sid=5156620
Comprehensive C++Builder link site:
http://www.buddydog.org/C++Builder/c++builder.html
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Nov 22, 2003 1:28 am Post subject: Re: TPageControl help file example |
|
|
"Jonathan Arnold" <jdarnold (AT) buddydog (DOT) org> wrote
| Quote: | To begin with, of course, it is using FormCreate and
FormDestroy - no-no in C++Builder.
|
Correct. But that is becaue most of Borland's examples in the help file are
just translations of the equivilent Delphi code. I don't think the
documentation writers take C++ issues into account when they write the
documentation, so many examples are wrong because of that.
| Quote: | But I also wonder about the deletes. I thought that the owner
was responsible for deleting
|
It is. But it is allowed to free an owned object manually. It will simply
remove itself from its Owner's internal lists so that the Owner does not try
to free it again later on.
| Quote: | so the "new TPageControl(this)" sets the owner to be the form,
and it will be responsible for deleting it.
|
It will.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|