Board index » cppbuilder » TPageControl help file example
Jonathan Arnold
![]() CBuilder Developer |
TPageControl help file example2003-11-22 09:07:57 AM cppbuilder41 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<iTabTitles;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: www.keen.com/categories/categorylist_expand.asp Comprehensive C++Builder link site: www.buddydog.org/C++Builder/c++builder.html |